Go tutorials and examples.https://learngolang.net/Recent content on Go tutorials and examples.Hugo -- gohugo.ioen-usThu, 16 Jan 2020 07:25:26 +0000Remove Elementhttps://learngolang.net/problems/solve-remove-element-problem-in-golang/Thu, 16 Jan 2020 07:25:26 +0000https://learngolang.net/problems/solve-remove-element-problem-in-golang/Remove Element Problem Statement Given an array nums and a value val, remove all instances of that value in-place and return the new length.
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
The order of elements can be changed. It doesn't matter what you leave beyond the new length.
Example 1:
Given nums = [3,2,2,3], val = 3, Your function should return length = 2, with the first two elements of nums being 2.Roman to Integerhttps://learngolang.net/problems/solve-roman-to-integer-problem-in-golang/Thu, 16 Jan 2020 07:20:26 +0000https://learngolang.net/problems/solve-roman-to-integer-problem-in-golang/Roman to Integer Problem Statement Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 For example, two is written as II in Roman numeral, just two one's added together. Twelve is written as, XII, which is simply X + II. The number twenty seven is written as XXVII, which is XX + V + II.Merge Two Sorted Listshttps://learngolang.net/problems/solve-merge-two-sorted-lists-problem-in-golang/Wed, 15 Jan 2020 07:23:26 +0000https://learngolang.net/problems/solve-merge-two-sorted-lists-problem-in-golang/Merge Two Sorted Lists Problem Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.
Example:
Input: 1->2->4, 1->3->4 Output: 1->1->2->3->4->4 Solution package main import "fmt" type ListNode struct { Val int Next *ListNode } func mergeTwoLists(l1 *ListNode, l2 *ListNode) *ListNode { var a *ListNode pos := &ListNode{Val: -1, Next: nil} a = pos for { if l1 !Valid Parentheseshttps://learngolang.net/problems/solve-valid-parentheses-problem-in-golang/Tue, 14 Jan 2020 07:22:26 +0000https://learngolang.net/problems/solve-valid-parentheses-problem-in-golang/Valid Parentheses Problem Statement Given a string containing just the characters ( , ) , { , }, [ , ]
determine if the input string is valid.
An input string is valid if:
Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Note that an empty string is also considered valid.
Example 1:
Input: "()" Output: true Example 2:Remove Outermost Parentheseshttps://learngolang.net/problems/solve-remove-outermost-parentheses-problem-in-golang/Fri, 10 Jan 2020 11:34:26 +0000https://learngolang.net/problems/solve-remove-outermost-parentheses-problem-in-golang/Remove Outermost Parentheses Problem Statement A valid parentheses string is either empty (""), “(” + A + “)", or A + B, where A and B are valid parentheses strings, and + represents string concatenation. For example, "", “()", “(())()", and “(()(()))" are all valid parentheses strings.
A valid parentheses string S is primitive if it is nonempty, and there does not exist a way to split it into S = A+B, with A and B nonempty valid parentheses strings.Valid Palindrome IIhttps://learngolang.net/problems/solve-valid-palindrome-ii-problem-in-golang/Sun, 05 Jan 2020 09:56:26 +0000https://learngolang.net/problems/solve-valid-palindrome-ii-problem-in-golang/Valid Palindrome II Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome.
Example 1 Input: "aba" Output: True Example 2 Input: "abca" Output: True Explanation: You could delete the character 'c'. Solution This is an easy one, basically compare ith and length - ith a.k.a j chars of the string and move inwards.
If letters do not match , there are two possibilities in this scenario:Reverse Integerhttps://learngolang.net/problems/solve-reverse-integer-problem-in-golang/Sun, 05 Jan 2020 07:18:26 +0000https://learngolang.net/problems/solve-reverse-integer-problem-in-golang/Reverse Integer Problem Statement Given a 32-bit signed integer, reverse digits of an integer.
The general technique here is simple, for a given positive integer:
Repeatedly divide by 10 and take the remainder. x%10 will result in isolating the last number of the digit . x = x/10 will get rid of the last number for next iteration, since we use integers and ignore the floating point values. Example 123 Reversed = 123%10 = 3 + (0 x 10) = 3 123/10 = **12**.Two Sumhttps://learngolang.net/problems/solve-two-sum-problem-in-golang/Sun, 05 Jan 2020 07:17:26 +0000https://learngolang.net/problems/solve-two-sum-problem-in-golang/Two Sum There are obviously many ways to solve this problem, the simplest and least performant a.k.a brute force way, is to go from left to right, have two pointers i and i+1 and in a sliding window fashion add arr[i] with arr[i+1], until we find the match, like shown below
package main import "fmt" func twosum(nums []int, target int) []int { var a []int L := len(nums) for i := 0; i < L; i++ { for j := i + 1; j < L; j++ { if nums[i]+nums[j] == target { a = append(a, i, j) } } } return a } func main() { arr := []int{3, 2, 4} fmt.Sum of Root To Leaf Binary Numbershttps://learngolang.net/problems/solve-sum-of-root-to-leaf-binary-numbers-problem-in-golang/Mon, 12 Aug 2019 11:35:26 +0000https://learngolang.net/problems/solve-sum-of-root-to-leaf-binary-numbers-problem-in-golang/Sum of Root To Leaf Binary NumbersBinary Prefix Divisible By 5https://learngolang.net/problems/solve-binary-prefix-divisible-by-5-problem-in-golang/Mon, 12 Aug 2019 11:33:26 +0000https://learngolang.net/problems/solve-binary-prefix-divisible-by-5-problem-in-golang/Binary Prefix Divisible By 5Partition Array Into Three Parts With Equal Sumhttps://learngolang.net/problems/solve-partition-array-into-three-parts-with-equal-sum-problem-in-golang/Mon, 12 Aug 2019 11:32:26 +0000https://learngolang.net/problems/solve-partition-array-into-three-parts-with-equal-sum-problem-in-golang/Partition Array Into Three Parts With Equal SumPairs of Songs With Total Durations Divisible by 60https://learngolang.net/problems/solve-pairs-of-songs-with-total-durations-divisible-by-60-problem-in-golang/Mon, 12 Aug 2019 11:31:26 +0000https://learngolang.net/problems/solve-pairs-of-songs-with-total-durations-divisible-by-60-problem-in-golang/Pairs of Songs With Total Durations Divisible by 60Complement of Base 10 Integerhttps://learngolang.net/problems/solve-complement-of-base-10-integer-problem-in-golang/Mon, 12 Aug 2019 11:30:26 +0000https://learngolang.net/problems/solve-complement-of-base-10-integer-problem-in-golang/Complement of Base 10 IntegerMaximize Sum Of Array After K Negationshttps://learngolang.net/problems/solve-maximize-sum-of-array-after-k-negations-problem-in-golang/Mon, 12 Aug 2019 11:29:26 +0000https://learngolang.net/problems/solve-maximize-sum-of-array-after-k-negations-problem-in-golang/Maximize Sum Of Array After K NegationsFind Common Charactershttps://learngolang.net/problems/solve-find-common-characters-problem-in-golang/Mon, 12 Aug 2019 11:28:26 +0000https://learngolang.net/problems/solve-find-common-characters-problem-in-golang/Find Common CharactersAvailable Captures for Rookhttps://learngolang.net/problems/solve-available-captures-for-rook-problem-in-golang/Mon, 12 Aug 2019 11:27:26 +0000https://learngolang.net/problems/solve-available-captures-for-rook-problem-in-golang/Available Captures for RookFind the Town Judgehttps://learngolang.net/problems/solve-find-the-town-judge-problem-in-golang/Mon, 12 Aug 2019 11:26:26 +0000https://learngolang.net/problems/solve-find-the-town-judge-problem-in-golang/Find the Town JudgeRotting Orangeshttps://learngolang.net/problems/solve-rotting-oranges-problem-in-golang/Mon, 12 Aug 2019 11:25:26 +0000https://learngolang.net/problems/solve-rotting-oranges-problem-in-golang/Rotting OrangesCousins in Binary Treehttps://learngolang.net/problems/solve-cousins-in-binary-tree-problem-in-golang/Mon, 12 Aug 2019 11:24:26 +0000https://learngolang.net/problems/solve-cousins-in-binary-tree-problem-in-golang/Cousins in Binary TreeAdd to Array-Form of Integerhttps://learngolang.net/problems/solve-add-to-array-form-of-integer-problem-in-golang/Mon, 12 Aug 2019 11:23:26 +0000https://learngolang.net/problems/solve-add-to-array-form-of-integer-problem-in-golang/Add to Array-Form of IntegerSum of Even Numbers After Querieshttps://learngolang.net/problems/solve-sum-of-even-numbers-after-queries-problem-in-golang/Mon, 12 Aug 2019 11:22:26 +0000https://learngolang.net/problems/solve-sum-of-even-numbers-after-queries-problem-in-golang/Sum of Even Numbers After QueriesSquares of a Sorted Arrayhttps://learngolang.net/problems/solve-squares-of-a-sorted-array-problem-in-golang/Mon, 12 Aug 2019 11:21:26 +0000https://learngolang.net/problems/solve-squares-of-a-sorted-array-problem-in-golang/Squares of a Sorted ArrayLargest Perimeter Trianglehttps://learngolang.net/problems/solve-largest-perimeter-triangle-problem-in-golang/Mon, 12 Aug 2019 11:20:26 +0000https://learngolang.net/problems/solve-largest-perimeter-triangle-problem-in-golang/Largest Perimeter TriangleFibonacci Numberhttps://learngolang.net/problems/solve-fibonacci-number-problem-in-golang/Mon, 12 Aug 2019 11:19:26 +0000https://learngolang.net/problems/solve-fibonacci-number-problem-in-golang/Fibonacci NumberPowerful Integershttps://learngolang.net/problems/solve-powerful-integers-problem-in-golang/Mon, 12 Aug 2019 11:18:26 +0000https://learngolang.net/problems/solve-powerful-integers-problem-in-golang/Powerful IntegersUnivalued Binary Treehttps://learngolang.net/problems/solve-univalued-binary-tree-problem-in-golang/Mon, 12 Aug 2019 11:17:26 +0000https://learngolang.net/problems/solve-univalued-binary-tree-problem-in-golang/Univalued Binary TreeN-Repeated Element in Size 2N Arrayhttps://learngolang.net/problems/solve-n-repeated-element-in-size-2n-array-problem-in-golang/Mon, 12 Aug 2019 11:16:26 +0000https://learngolang.net/problems/solve-n-repeated-element-in-size-2n-array-problem-in-golang/N-Repeated Element in Size 2N ArrayVerifying an Alien Dictionaryhttps://learngolang.net/problems/solve-verifying-an-alien-dictionary-problem-in-golang/Mon, 12 Aug 2019 11:15:26 +0000https://learngolang.net/problems/solve-verifying-an-alien-dictionary-problem-in-golang/Verifying an Alien DictionaryLargest Time for Given Digitshttps://learngolang.net/problems/solve-largest-time-for-given-digits-problem-in-golang/Mon, 12 Aug 2019 11:14:26 +0000https://learngolang.net/problems/solve-largest-time-for-given-digits-problem-in-golang/Largest Time for Given DigitsDelete Columns to Make Sortedhttps://learngolang.net/problems/solve-delete-columns-to-make-sorted-problem-in-golang/Mon, 12 Aug 2019 11:13:26 +0000https://learngolang.net/problems/solve-delete-columns-to-make-sorted-problem-in-golang/Delete Columns to Make SortedDI String Matchhttps://learngolang.net/problems/solve-di-string-match-problem-in-golang/Mon, 12 Aug 2019 11:12:26 +0000https://learngolang.net/problems/solve-di-string-match-problem-in-golang/DI String MatchValid Mountain Arrayhttps://learngolang.net/problems/solve-valid-mountain-array-problem-in-golang/Mon, 12 Aug 2019 11:11:26 +0000https://learngolang.net/problems/solve-valid-mountain-array-problem-in-golang/Valid Mountain ArrayReorder Log Fileshttps://learngolang.net/problems/solve-reorder-log-files-problem-in-golang/Mon, 12 Aug 2019 11:10:26 +0000https://learngolang.net/problems/solve-reorder-log-files-problem-in-golang/Reorder Log FilesNumber of Recent Callshttps://learngolang.net/problems/solve-number-of-recent-calls-problem-in-golang/Mon, 12 Aug 2019 11:09:26 +0000https://learngolang.net/problems/solve-number-of-recent-calls-problem-in-golang/Number of Recent CallsUnique Email Addresseshttps://learngolang.net/problems/solve-unique-email-addresses-problem-in-golang/Mon, 12 Aug 2019 11:08:26 +0000https://learngolang.net/problems/solve-unique-email-addresses-problem-in-golang/Unique Email AddressesLong Pressed Namehttps://learngolang.net/problems/solve-long-pressed-name-problem-in-golang/Mon, 12 Aug 2019 11:07:26 +0000https://learngolang.net/problems/solve-long-pressed-name-problem-in-golang/Long Pressed NameSort Array By Parity IIhttps://learngolang.net/problems/solve-sort-array-by-parity-ii-problem-in-golang/Mon, 12 Aug 2019 11:06:26 +0000https://learngolang.net/problems/solve-sort-array-by-parity-ii-problem-in-golang/Sort Array By Parity IIReverse Only Lettershttps://learngolang.net/problems/solve-reverse-only-letters-problem-in-golang/Mon, 12 Aug 2019 11:05:26 +0000https://learngolang.net/problems/solve-reverse-only-letters-problem-in-golang/Reverse Only LettersX of a Kind in a Deck of Cardshttps://learngolang.net/problems/solve-x-of-a-kind-in-a-deck-of-cards-problem-in-golang/Mon, 12 Aug 2019 11:04:26 +0000https://learngolang.net/problems/solve-x-of-a-kind-in-a-deck-of-cards-problem-in-golang/X of a Kind in a Deck of CardsSmallest Range Ihttps://learngolang.net/problems/solve-smallest-range-i-problem-in-golang/Mon, 12 Aug 2019 11:03:26 +0000https://learngolang.net/problems/solve-smallest-range-i-problem-in-golang/Smallest Range ISort Array By Parityhttps://learngolang.net/problems/solve-sort-array-by-parity-problem-in-golang/Mon, 12 Aug 2019 11:02:26 +0000https://learngolang.net/problems/solve-sort-array-by-parity-problem-in-golang/Sort Array By ParityIncreasing Order Search Treehttps://learngolang.net/problems/solve-increasing-order-search-tree-problem-in-golang/Mon, 12 Aug 2019 11:01:26 +0000https://learngolang.net/problems/solve-increasing-order-search-tree-problem-in-golang/Increasing Order Search TreeMonotonic Arrayhttps://learngolang.net/problems/solve-monotonic-array-problem-in-golang/Mon, 12 Aug 2019 11:00:26 +0000https://learngolang.net/problems/solve-monotonic-array-problem-in-golang/Monotonic ArrayGroups of Special-Equivalent Stringshttps://learngolang.net/problems/solve-groups-of-special-equivalent-strings-problem-in-golang/Mon, 12 Aug 2019 10:59:26 +0000https://learngolang.net/problems/solve-groups-of-special-equivalent-strings-problem-in-golang/Groups of Special-Equivalent StringsSurface Area of 3D Shapeshttps://learngolang.net/problems/solve-surface-area-of-3d-shapes-problem-in-golang/Mon, 12 Aug 2019 10:58:26 +0000https://learngolang.net/problems/solve-surface-area-of-3d-shapes-problem-in-golang/Surface Area of 3D ShapesFair Candy Swaphttps://learngolang.net/problems/solve-fair-candy-swap-problem-in-golang/Mon, 12 Aug 2019 10:57:26 +0000https://learngolang.net/problems/solve-fair-candy-swap-problem-in-golang/Fair Candy SwapUncommon Words from Two Sentenceshttps://learngolang.net/problems/solve-uncommon-words-from-two-sentences-problem-in-golang/Mon, 12 Aug 2019 10:56:26 +0000https://learngolang.net/problems/solve-uncommon-words-from-two-sentences-problem-in-golang/Uncommon Words from Two SentencesProjection Area of 3D Shapeshttps://learngolang.net/problems/solve-projection-area-of-3d-shapes-problem-in-golang/Mon, 12 Aug 2019 10:55:26 +0000https://learngolang.net/problems/solve-projection-area-of-3d-shapes-problem-in-golang/Projection Area of 3D ShapesMiddle of the Linked Listhttps://learngolang.net/problems/solve-middle-of-the-linked-list-problem-in-golang/Mon, 12 Aug 2019 10:54:26 +0000https://learngolang.net/problems/solve-middle-of-the-linked-list-problem-in-golang/Middle of the Linked ListWalking Robot Simulationhttps://learngolang.net/problems/solve-walking-robot-simulation-problem-in-golang/Mon, 12 Aug 2019 10:53:26 +0000https://learngolang.net/problems/solve-walking-robot-simulation-problem-in-golang/Walking Robot SimulationLeaf-Similar Treeshttps://learngolang.net/problems/solve-leaf-similar-trees-problem-in-golang/Mon, 12 Aug 2019 10:52:26 +0000https://learngolang.net/problems/solve-leaf-similar-trees-problem-in-golang/Leaf-Similar TreesBinary Gaphttps://learngolang.net/problems/solve-binary-gap-problem-in-golang/Mon, 12 Aug 2019 10:51:26 +0000https://learngolang.net/problems/solve-binary-gap-problem-in-golang/Binary GapTranspose Matrixhttps://learngolang.net/problems/solve-transpose-matrix-problem-in-golang/Mon, 12 Aug 2019 10:50:26 +0000https://learngolang.net/problems/solve-transpose-matrix-problem-in-golang/Transpose MatrixLemonade Changehttps://learngolang.net/problems/solve-lemonade-change-problem-in-golang/Mon, 12 Aug 2019 10:49:26 +0000https://learngolang.net/problems/solve-lemonade-change-problem-in-golang/Lemonade ChangeBuddy Stringshttps://learngolang.net/problems/solve-buddy-strings-problem-in-golang/Mon, 12 Aug 2019 10:48:26 +0000https://learngolang.net/problems/solve-buddy-strings-problem-in-golang/Buddy StringsPeak Index in a Mountain Arrayhttps://learngolang.net/problems/solve-peak-index-in-a-mountain-array-problem-in-golang/Mon, 12 Aug 2019 10:47:26 +0000https://learngolang.net/problems/solve-peak-index-in-a-mountain-array-problem-in-golang/Peak Index in a Mountain ArrayMaximize Distance to Closest Personhttps://learngolang.net/problems/solve-maximize-distance-to-closest-person-problem-in-golang/Mon, 12 Aug 2019 10:46:26 +0000https://learngolang.net/problems/solve-maximize-distance-to-closest-person-problem-in-golang/Maximize Distance to Closest PersonBackspace String Comparehttps://learngolang.net/problems/solve-backspace-string-compare-problem-in-golang/Mon, 12 Aug 2019 10:45:26 +0000https://learngolang.net/problems/solve-backspace-string-compare-problem-in-golang/Backspace String CompareMagic Squares In Gridhttps://learngolang.net/problems/solve-magic-squares-in-grid-problem-in-golang/Mon, 12 Aug 2019 10:44:26 +0000https://learngolang.net/problems/solve-magic-squares-in-grid-problem-in-golang/Magic Squares In GridRectangle Overlaphttps://learngolang.net/problems/solve-rectangle-overlap-problem-in-golang/Mon, 12 Aug 2019 10:43:26 +0000https://learngolang.net/problems/solve-rectangle-overlap-problem-in-golang/Rectangle OverlapFlipping an Imagehttps://learngolang.net/problems/solve-flipping-an-image-problem-in-golang/Mon, 12 Aug 2019 10:42:26 +0000https://learngolang.net/problems/solve-flipping-an-image-problem-in-golang/Flipping an ImagePositions of Large Groupshttps://learngolang.net/problems/solve-positions-of-large-groups-problem-in-golang/Mon, 12 Aug 2019 10:41:26 +0000https://learngolang.net/problems/solve-positions-of-large-groups-problem-in-golang/Positions of Large GroupsGoat Latinhttps://learngolang.net/problems/solve-goat-latin-problem-in-golang/Mon, 12 Aug 2019 10:40:26 +0000https://learngolang.net/problems/solve-goat-latin-problem-in-golang/Goat LatinShortest Distance to a Characterhttps://learngolang.net/problems/solve-shortest-distance-to-a-character-problem-in-golang/Mon, 12 Aug 2019 10:39:26 +0000https://learngolang.net/problems/solve-shortest-distance-to-a-character-problem-in-golang/Shortest Distance to a CharacterDesign Linked Listhttps://learngolang.net/problems/solve-design-linked-list-problem-in-golang/Mon, 12 Aug 2019 10:38:26 +0000https://learngolang.net/problems/solve-design-linked-list-problem-in-golang/Design Linked ListMost Common Wordhttps://learngolang.net/problems/solve-most-common-word-problem-in-golang/Mon, 12 Aug 2019 10:37:26 +0000https://learngolang.net/problems/solve-most-common-word-problem-in-golang/Most Common WordLargest Triangle Areahttps://learngolang.net/problems/solve-largest-triangle-area-problem-in-golang/Mon, 12 Aug 2019 10:36:26 +0000https://learngolang.net/problems/solve-largest-triangle-area-problem-in-golang/Largest Triangle AreaSubdomain Visit Counthttps://learngolang.net/problems/solve-subdomain-visit-count-problem-in-golang/Mon, 12 Aug 2019 10:35:26 +0000https://learngolang.net/problems/solve-subdomain-visit-count-problem-in-golang/Subdomain Visit CountNumber of Lines To Write Stringhttps://learngolang.net/problems/solve-number-of-lines-to-write-string-problem-in-golang/Mon, 12 Aug 2019 10:34:26 +0000https://learngolang.net/problems/solve-number-of-lines-to-write-string-problem-in-golang/Number of Lines To Write StringUnique Morse Code Wordshttps://learngolang.net/problems/solve-unique-morse-code-words-problem-in-golang/Mon, 12 Aug 2019 10:33:26 +0000https://learngolang.net/problems/solve-unique-morse-code-words-problem-in-golang/Unique Morse Code WordsDesign HashMaphttps://learngolang.net/problems/solve-design-hashmap-problem-in-golang/Mon, 12 Aug 2019 10:32:26 +0000https://learngolang.net/problems/solve-design-hashmap-problem-in-golang/Design HashMapDesign HashSethttps://learngolang.net/problems/solve-design-hashset-problem-in-golang/Mon, 12 Aug 2019 10:31:26 +0000https://learngolang.net/problems/solve-design-hashset-problem-in-golang/Design HashSetRotate Stringhttps://learngolang.net/problems/solve-rotate-string-problem-in-golang/Mon, 12 Aug 2019 10:30:26 +0000https://learngolang.net/problems/solve-rotate-string-problem-in-golang/Rotate StringRotated Digitshttps://learngolang.net/problems/solve-rotated-digits-problem-in-golang/Mon, 12 Aug 2019 10:29:26 +0000https://learngolang.net/problems/solve-rotated-digits-problem-in-golang/Rotated DigitsLetter Case Permutationhttps://learngolang.net/problems/solve-letter-case-permutation-problem-in-golang/Mon, 12 Aug 2019 10:28:26 +0000https://learngolang.net/problems/solve-letter-case-permutation-problem-in-golang/Letter Case PermutationMinimum Distance Between BST Nodeshttps://learngolang.net/problems/solve-minimum-distance-between-bst-nodes-problem-in-golang/Mon, 12 Aug 2019 10:27:26 +0000https://learngolang.net/problems/solve-minimum-distance-between-bst-nodes-problem-in-golang/Minimum Distance Between BST NodesBinary Searchhttps://learngolang.net/problems/solve-binary-search-problem-in-golang/Mon, 12 Aug 2019 10:26:26 +0000https://learngolang.net/problems/solve-binary-search-problem-in-golang/Binary SearchKth Largest Element in a Streamhttps://learngolang.net/problems/solve-kth-largest-element-in-a-stream-problem-in-golang/Mon, 12 Aug 2019 10:25:26 +0000https://learngolang.net/problems/solve-kth-largest-element-in-a-stream-problem-in-golang/Kth Largest Element in a StreamSearch in a Binary Search Treehttps://learngolang.net/problems/solve-search-in-a-binary-search-tree-problem-in-golang/Mon, 12 Aug 2019 10:24:26 +0000https://learngolang.net/problems/solve-search-in-a-binary-search-tree-problem-in-golang/Search in a Binary Search TreeJewels and Stoneshttps://learngolang.net/problems/solve-jewels-and-stones-problem-in-golang/Mon, 12 Aug 2019 10:23:26 +0000https://learngolang.net/problems/solve-jewels-and-stones-problem-in-golang/Jewels and StonesToeplitz Matrixhttps://learngolang.net/problems/solve-toeplitz-matrix-problem-in-golang/Mon, 12 Aug 2019 10:22:26 +0000https://learngolang.net/problems/solve-toeplitz-matrix-problem-in-golang/Toeplitz MatrixN-ary Tree Postorder Traversalhttps://learngolang.net/problems/solve-n-ary-tree-postorder-traversal-problem-in-golang/Mon, 12 Aug 2019 10:21:26 +0000https://learngolang.net/problems/solve-n-ary-tree-postorder-traversal-problem-in-golang/N-ary Tree Postorder TraversalN-ary Tree Preorder Traversalhttps://learngolang.net/problems/solve-n-ary-tree-preorder-traversal-problem-in-golang/Mon, 12 Aug 2019 10:20:26 +0000https://learngolang.net/problems/solve-n-ary-tree-preorder-traversal-problem-in-golang/N-ary Tree Preorder TraversalMaximum Depth of N-ary Treehttps://learngolang.net/problems/solve-maximum-depth-of-n-ary-tree-problem-in-golang/Mon, 12 Aug 2019 10:19:26 +0000https://learngolang.net/problems/solve-maximum-depth-of-n-ary-tree-problem-in-golang/Maximum Depth of N-ary TreeQuad Tree Intersectionhttps://learngolang.net/problems/solve-quad-tree-intersection-problem-in-golang/Mon, 12 Aug 2019 10:18:26 +0000https://learngolang.net/problems/solve-quad-tree-intersection-problem-in-golang/Quad Tree IntersectionConstruct Quad Treehttps://learngolang.net/problems/solve-construct-quad-tree-problem-in-golang/Mon, 12 Aug 2019 10:17:26 +0000https://learngolang.net/problems/solve-construct-quad-tree-problem-in-golang/Construct Quad TreePrime Number of Set Bits in Binary Representationhttps://learngolang.net/problems/solve-prime-number-of-set-bits-in-binary-representation-problem-in-golang/Mon, 12 Aug 2019 10:16:26 +0000https://learngolang.net/problems/solve-prime-number-of-set-bits-in-binary-representation-problem-in-golang/Prime Number of Set Bits in Binary RepresentationN-ary Tree Level Order Traversalhttps://learngolang.net/problems/solve-n-ary-tree-level-order-traversal-problem-in-golang/Mon, 12 Aug 2019 10:15:26 +0000https://learngolang.net/problems/solve-n-ary-tree-level-order-traversal-problem-in-golang/N-ary Tree Level Order TraversalReach a Numberhttps://learngolang.net/problems/solve-reach-a-number-problem-in-golang/Mon, 12 Aug 2019 10:14:26 +0000https://learngolang.net/problems/solve-reach-a-number-problem-in-golang/Reach a NumberShortest Completing Wordhttps://learngolang.net/problems/solve-shortest-completing-word-problem-in-golang/Mon, 12 Aug 2019 10:13:26 +0000https://learngolang.net/problems/solve-shortest-completing-word-problem-in-golang/Shortest Completing WordLargest Number At Least Twice of Othershttps://learngolang.net/problems/solve-largest-number-at-least-twice-of-others-problem-in-golang/Mon, 12 Aug 2019 10:12:26 +0000https://learngolang.net/problems/solve-largest-number-at-least-twice-of-others-problem-in-golang/Largest Number At Least Twice of OthersMin Cost Climbing Stairshttps://learngolang.net/problems/solve-min-cost-climbing-stairs-problem-in-golang/Mon, 12 Aug 2019 10:11:26 +0000https://learngolang.net/problems/solve-min-cost-climbing-stairs-problem-in-golang/Min Cost Climbing StairsFind Smallest Letter Greater Than Targethttps://learngolang.net/problems/solve-find-smallest-letter-greater-than-target-problem-in-golang/Mon, 12 Aug 2019 10:10:26 +0000https://learngolang.net/problems/solve-find-smallest-letter-greater-than-target-problem-in-golang/Find Smallest Letter Greater Than TargetTo Lower Casehttps://learngolang.net/problems/solve-to-lower-case-problem-in-golang/Mon, 12 Aug 2019 10:09:26 +0000https://learngolang.net/problems/solve-to-lower-case-problem-in-golang/To Lower CaseFlood Fillhttps://learngolang.net/problems/solve-flood-fill-problem-in-golang/Mon, 12 Aug 2019 10:08:26 +0000https://learngolang.net/problems/solve-flood-fill-problem-in-golang/Flood FillSelf Dividing Numbershttps://learngolang.net/problems/solve-self-dividing-numbers-problem-in-golang/Mon, 12 Aug 2019 10:07:26 +0000https://learngolang.net/problems/solve-self-dividing-numbers-problem-in-golang/Self Dividing NumbersFind Pivot Indexhttps://learngolang.net/problems/solve-find-pivot-index-problem-in-golang/Mon, 12 Aug 2019 10:06:26 +0000https://learngolang.net/problems/solve-find-pivot-index-problem-in-golang/Find Pivot IndexLongest Word in Dictionaryhttps://learngolang.net/problems/solve-longest-word-in-dictionary-problem-in-golang/Mon, 12 Aug 2019 10:05:26 +0000https://learngolang.net/problems/solve-longest-word-in-dictionary-problem-in-golang/Longest Word in Dictionary1-bit and 2-bit Charactershttps://learngolang.net/problems/solve-1-bit-and-2-bit-characters-problem-in-golang/Mon, 12 Aug 2019 10:04:26 +0000https://learngolang.net/problems/solve-1-bit-and-2-bit-characters-problem-in-golang/1-bit and 2-bit CharactersDegree of an Arrayhttps://learngolang.net/problems/solve-degree-of-an-array-problem-in-golang/Mon, 12 Aug 2019 10:03:26 +0000https://learngolang.net/problems/solve-degree-of-an-array-problem-in-golang/Degree of an ArrayCount Binary Substringshttps://learngolang.net/problems/solve-count-binary-substrings-problem-in-golang/Mon, 12 Aug 2019 10:02:26 +0000https://learngolang.net/problems/solve-count-binary-substrings-problem-in-golang/Count Binary SubstringsBinary Number with Alternating Bitshttps://learngolang.net/problems/solve-binary-number-with-alternating-bits-problem-in-golang/Mon, 12 Aug 2019 10:01:26 +0000https://learngolang.net/problems/solve-binary-number-with-alternating-bits-problem-in-golang/Binary Number with Alternating BitsEmployee Importancehttps://learngolang.net/problems/solve-employee-importance-problem-in-golang/Mon, 12 Aug 2019 10:00:26 +0000https://learngolang.net/problems/solve-employee-importance-problem-in-golang/Employee ImportanceLongest Univalue Pathhttps://learngolang.net/problems/solve-longest-univalue-path-problem-in-golang/Mon, 12 Aug 2019 09:59:26 +0000https://learngolang.net/problems/solve-longest-univalue-path-problem-in-golang/Longest Univalue PathRepeated String Matchhttps://learngolang.net/problems/solve-repeated-string-match-problem-in-golang/Mon, 12 Aug 2019 09:58:26 +0000https://learngolang.net/problems/solve-repeated-string-match-problem-in-golang/Repeated String MatchBaseball Gamehttps://learngolang.net/problems/solve-baseball-game-problem-in-golang/Mon, 12 Aug 2019 09:57:26 +0000https://learngolang.net/problems/solve-baseball-game-problem-in-golang/Baseball GameLongest Continuous Increasing Subsequencehttps://learngolang.net/problems/solve-longest-continuous-increasing-subsequence-problem-in-golang/Mon, 12 Aug 2019 09:55:26 +0000https://learngolang.net/problems/solve-longest-continuous-increasing-subsequence-problem-in-golang/Longest Continuous Increasing SubsequenceSecond Minimum Node In a Binary Treehttps://learngolang.net/problems/solve-second-minimum-node-in-a-binary-tree-problem-in-golang/Mon, 12 Aug 2019 09:54:26 +0000https://learngolang.net/problems/solve-second-minimum-node-in-a-binary-tree-problem-in-golang/Second Minimum Node In a Binary TreeTrim a Binary Search Treehttps://learngolang.net/problems/solve-trim-a-binary-search-tree-problem-in-golang/Mon, 12 Aug 2019 09:53:26 +0000https://learngolang.net/problems/solve-trim-a-binary-search-tree-problem-in-golang/Trim a Binary Search TreeNon-decreasing Arrayhttps://learngolang.net/problems/solve-non-decreasing-array-problem-in-golang/Mon, 12 Aug 2019 09:52:26 +0000https://learngolang.net/problems/solve-non-decreasing-array-problem-in-golang/Non-decreasing ArrayImage Smootherhttps://learngolang.net/problems/solve-image-smoother-problem-in-golang/Mon, 12 Aug 2019 09:51:26 +0000https://learngolang.net/problems/solve-image-smoother-problem-in-golang/Image SmootherRobot Return to Originhttps://learngolang.net/problems/solve-robot-return-to-origin-problem-in-golang/Mon, 12 Aug 2019 09:50:26 +0000https://learngolang.net/problems/solve-robot-return-to-origin-problem-in-golang/Robot Return to OriginTwo Sum IV - Input is a BSThttps://learngolang.net/problems/solve-two-sum-iv-input-is-a-bst-problem-in-golang/Mon, 12 Aug 2019 09:49:26 +0000https://learngolang.net/problems/solve-two-sum-iv-input-is-a-bst-problem-in-golang/Two Sum IV - Input is a BSTSet Mismatchhttps://learngolang.net/problems/solve-set-mismatch-problem-in-golang/Mon, 12 Aug 2019 09:48:26 +0000https://learngolang.net/problems/solve-set-mismatch-problem-in-golang/Set MismatchMaximum Average Subarray Ihttps://learngolang.net/problems/solve-maximum-average-subarray-i-problem-in-golang/Mon, 12 Aug 2019 09:47:26 +0000https://learngolang.net/problems/solve-maximum-average-subarray-i-problem-in-golang/Maximum Average Subarray IAverage of Levels in Binary Treehttps://learngolang.net/problems/solve-average-of-levels-in-binary-tree-problem-in-golang/Mon, 12 Aug 2019 09:46:26 +0000https://learngolang.net/problems/solve-average-of-levels-in-binary-tree-problem-in-golang/Average of Levels in Binary TreeSum of Square Numbershttps://learngolang.net/problems/solve-sum-of-square-numbers-problem-in-golang/Mon, 12 Aug 2019 09:45:26 +0000https://learngolang.net/problems/solve-sum-of-square-numbers-problem-in-golang/Sum of Square NumbersMaximum Product of Three Numbershttps://learngolang.net/problems/solve-maximum-product-of-three-numbers-problem-in-golang/Mon, 12 Aug 2019 09:44:26 +0000https://learngolang.net/problems/solve-maximum-product-of-three-numbers-problem-in-golang/Maximum Product of Three NumbersSwap Salaryhttps://learngolang.net/problems/solve-swap-salary-problem-in-golang/Mon, 12 Aug 2019 09:43:26 +0000https://learngolang.net/problems/solve-swap-salary-problem-in-golang/Swap SalaryNot Boring Movieshttps://learngolang.net/problems/solve-not-boring-movies-problem-in-golang/Mon, 12 Aug 2019 09:42:26 +0000https://learngolang.net/problems/solve-not-boring-movies-problem-in-golang/Not Boring MoviesMerge Two Binary Treeshttps://learngolang.net/problems/solve-merge-two-binary-trees-problem-in-golang/Mon, 12 Aug 2019 09:41:26 +0000https://learngolang.net/problems/solve-merge-two-binary-trees-problem-in-golang/Merge Two Binary TreesConstruct String from Binary Treehttps://learngolang.net/problems/solve-construct-string-from-binary-tree-problem-in-golang/Mon, 12 Aug 2019 09:40:26 +0000https://learngolang.net/problems/solve-construct-string-from-binary-tree-problem-in-golang/Construct String from Binary TreeCan Place Flowershttps://learngolang.net/problems/solve-can-place-flowers-problem-in-golang/Mon, 12 Aug 2019 09:39:26 +0000https://learngolang.net/problems/solve-can-place-flowers-problem-in-golang/Can Place FlowersMinimum Index Sum of Two Listshttps://learngolang.net/problems/solve-minimum-index-sum-of-two-lists-problem-in-golang/Mon, 12 Aug 2019 09:38:26 +0000https://learngolang.net/problems/solve-minimum-index-sum-of-two-lists-problem-in-golang/Minimum Index Sum of Two ListsRange Addition IIhttps://learngolang.net/problems/solve-range-addition-ii-problem-in-golang/Mon, 12 Aug 2019 09:37:26 +0000https://learngolang.net/problems/solve-range-addition-ii-problem-in-golang/Range Addition IIClasses More Than 5 Studentshttps://learngolang.net/problems/solve-classes-more-than-5-students-problem-in-golang/Mon, 12 Aug 2019 09:36:26 +0000https://learngolang.net/problems/solve-classes-more-than-5-students-problem-in-golang/Classes More Than 5 StudentsBig Countrieshttps://learngolang.net/problems/solve-big-countries-problem-in-golang/Mon, 12 Aug 2019 09:35:26 +0000https://learngolang.net/problems/solve-big-countries-problem-in-golang/Big CountriesLongest Harmonious Subsequencehttps://learngolang.net/problems/solve-longest-harmonious-subsequence-problem-in-golang/Mon, 12 Aug 2019 09:34:26 +0000https://learngolang.net/problems/solve-longest-harmonious-subsequence-problem-in-golang/Longest Harmonious SubsequenceShortest Unsorted Continuous Subarrayhttps://learngolang.net/problems/solve-shortest-unsorted-continuous-subarray-problem-in-golang/Mon, 12 Aug 2019 09:33:26 +0000https://learngolang.net/problems/solve-shortest-unsorted-continuous-subarray-problem-in-golang/Shortest Unsorted Continuous SubarrayDistribute Candieshttps://learngolang.net/problems/solve-distribute-candies-problem-in-golang/Mon, 12 Aug 2019 09:32:26 +0000https://learngolang.net/problems/solve-distribute-candies-problem-in-golang/Distribute CandiesSubtree of Another Treehttps://learngolang.net/problems/solve-subtree-of-another-tree-problem-in-golang/Mon, 12 Aug 2019 09:31:26 +0000https://learngolang.net/problems/solve-subtree-of-another-tree-problem-in-golang/Subtree of Another TreeReshape the Matrixhttps://learngolang.net/problems/solve-reshape-the-matrix-problem-in-golang/Mon, 12 Aug 2019 09:30:26 +0000https://learngolang.net/problems/solve-reshape-the-matrix-problem-in-golang/Reshape the MatrixBinary Tree Tilthttps://learngolang.net/problems/solve-binary-tree-tilt-problem-in-golang/Mon, 12 Aug 2019 09:29:26 +0000https://learngolang.net/problems/solve-binary-tree-tilt-problem-in-golang/Binary Tree TiltArray Partition Ihttps://learngolang.net/problems/solve-array-partition-i-problem-in-golang/Mon, 12 Aug 2019 09:28:26 +0000https://learngolang.net/problems/solve-array-partition-i-problem-in-golang/Array Partition IReverse Words in a String IIIhttps://learngolang.net/problems/solve-reverse-words-in-a-string-iii-problem-in-golang/Mon, 12 Aug 2019 09:27:26 +0000https://learngolang.net/problems/solve-reverse-words-in-a-string-iii-problem-in-golang/Reverse Words in a String IIIStudent Attendance Record Ihttps://learngolang.net/problems/solve-student-attendance-record-i-problem-in-golang/Mon, 12 Aug 2019 09:26:26 +0000https://learngolang.net/problems/solve-student-attendance-record-i-problem-in-golang/Student Attendance Record IDiameter of Binary Treehttps://learngolang.net/problems/solve-diameter-of-binary-tree-problem-in-golang/Mon, 12 Aug 2019 09:25:26 +0000https://learngolang.net/problems/solve-diameter-of-binary-tree-problem-in-golang/Diameter of Binary TreeReverse String IIhttps://learngolang.net/problems/solve-reverse-string-ii-problem-in-golang/Mon, 12 Aug 2019 09:24:26 +0000https://learngolang.net/problems/solve-reverse-string-ii-problem-in-golang/Reverse String IIConvert BST to Greater Treehttps://learngolang.net/problems/solve-convert-bst-to-greater-tree-problem-in-golang/Mon, 12 Aug 2019 09:23:26 +0000https://learngolang.net/problems/solve-convert-bst-to-greater-tree-problem-in-golang/Convert BST to Greater TreeK-diff Pairs in an Arrayhttps://learngolang.net/problems/solve-k-diff-pairs-in-an-array-problem-in-golang/Mon, 12 Aug 2019 09:22:26 +0000https://learngolang.net/problems/solve-k-diff-pairs-in-an-array-problem-in-golang/K-diff Pairs in an ArrayMinimum Absolute Difference in BSThttps://learngolang.net/problems/solve-minimum-absolute-difference-in-bst-problem-in-golang/Mon, 12 Aug 2019 09:21:26 +0000https://learngolang.net/problems/solve-minimum-absolute-difference-in-bst-problem-in-golang/Minimum Absolute Difference in BSTLongest Uncommon Subsequence Ihttps://learngolang.net/problems/solve-longest-uncommon-subsequence-i-problem-in-golang/Mon, 12 Aug 2019 09:20:26 +0000https://learngolang.net/problems/solve-longest-uncommon-subsequence-i-problem-in-golang/Longest Uncommon Subsequence IDetect Capitalhttps://learngolang.net/problems/solve-detect-capital-problem-in-golang/Mon, 12 Aug 2019 09:19:26 +0000https://learngolang.net/problems/solve-detect-capital-problem-in-golang/Detect CapitalPerfect Numberhttps://learngolang.net/problems/solve-perfect-number-problem-in-golang/Mon, 12 Aug 2019 09:18:26 +0000https://learngolang.net/problems/solve-perfect-number-problem-in-golang/Perfect NumberRelative Rankshttps://learngolang.net/problems/solve-relative-ranks-problem-in-golang/Mon, 12 Aug 2019 09:17:26 +0000https://learngolang.net/problems/solve-relative-ranks-problem-in-golang/Relative RanksBase 7https://learngolang.net/problems/solve-base-7-problem-in-golang/Mon, 12 Aug 2019 09:16:26 +0000https://learngolang.net/problems/solve-base-7-problem-in-golang/Base 7Find Mode in Binary Search Treehttps://learngolang.net/problems/solve-find-mode-in-binary-search-tree-problem-in-golang/Mon, 12 Aug 2019 09:15:26 +0000https://learngolang.net/problems/solve-find-mode-in-binary-search-tree-problem-in-golang/Find Mode in Binary Search TreeKeyboard Rowhttps://learngolang.net/problems/solve-keyboard-row-problem-in-golang/Mon, 12 Aug 2019 09:14:26 +0000https://learngolang.net/problems/solve-keyboard-row-problem-in-golang/Keyboard RowNext Greater Element Ihttps://learngolang.net/problems/solve-next-greater-element-i-problem-in-golang/Mon, 12 Aug 2019 09:13:26 +0000https://learngolang.net/problems/solve-next-greater-element-i-problem-in-golang/Next Greater Element IConstruct the Rectanglehttps://learngolang.net/problems/solve-construct-the-rectangle-problem-in-golang/Mon, 12 Aug 2019 09:12:26 +0000https://learngolang.net/problems/solve-construct-the-rectangle-problem-in-golang/Construct the RectangleMax Consecutive Oneshttps://learngolang.net/problems/solve-max-consecutive-ones-problem-in-golang/Mon, 12 Aug 2019 09:11:26 +0000https://learngolang.net/problems/solve-max-consecutive-ones-problem-in-golang/Max Consecutive OnesLicense Key Formattinghttps://learngolang.net/problems/solve-license-key-formatting-problem-in-golang/Mon, 12 Aug 2019 09:10:26 +0000https://learngolang.net/problems/solve-license-key-formatting-problem-in-golang/License Key FormattingNumber Complementhttps://learngolang.net/problems/solve-number-complement-problem-in-golang/Mon, 12 Aug 2019 09:09:26 +0000https://learngolang.net/problems/solve-number-complement-problem-in-golang/Number ComplementHeatershttps://learngolang.net/problems/solve-heaters-problem-in-golang/Mon, 12 Aug 2019 09:08:26 +0000https://learngolang.net/problems/solve-heaters-problem-in-golang/HeatersIsland Perimeterhttps://learngolang.net/problems/solve-island-perimeter-problem-in-golang/Mon, 12 Aug 2019 09:07:26 +0000https://learngolang.net/problems/solve-island-perimeter-problem-in-golang/Island PerimeterHamming Distancehttps://learngolang.net/problems/solve-hamming-distance-problem-in-golang/Mon, 12 Aug 2019 09:06:26 +0000https://learngolang.net/problems/solve-hamming-distance-problem-in-golang/Hamming DistanceRepeated Substring Patternhttps://learngolang.net/problems/solve-repeated-substring-pattern-problem-in-golang/Mon, 12 Aug 2019 09:05:26 +0000https://learngolang.net/problems/solve-repeated-substring-pattern-problem-in-golang/Repeated Substring PatternAssign Cookieshttps://learngolang.net/problems/solve-assign-cookies-problem-in-golang/Mon, 12 Aug 2019 09:04:26 +0000https://learngolang.net/problems/solve-assign-cookies-problem-in-golang/Assign CookiesMinimum Moves to Equal Array Elementshttps://learngolang.net/problems/solve-minimum-moves-to-equal-array-elements-problem-in-golang/Mon, 12 Aug 2019 09:03:26 +0000https://learngolang.net/problems/solve-minimum-moves-to-equal-array-elements-problem-in-golang/Minimum Moves to Equal Array ElementsFind All Numbers Disappeared in an Arrayhttps://learngolang.net/problems/solve-find-all-numbers-disappeared-in-an-array-problem-in-golang/Mon, 12 Aug 2019 09:02:26 +0000https://learngolang.net/problems/solve-find-all-numbers-disappeared-in-an-array-problem-in-golang/Find All Numbers Disappeared in an ArrayNumber of Boomerangshttps://learngolang.net/problems/solve-number-of-boomerangs-problem-in-golang/Mon, 12 Aug 2019 09:01:26 +0000https://learngolang.net/problems/solve-number-of-boomerangs-problem-in-golang/Number of BoomerangsString Compressionhttps://learngolang.net/problems/solve-string-compression-problem-in-golang/Mon, 12 Aug 2019 09:00:26 +0000https://learngolang.net/problems/solve-string-compression-problem-in-golang/String CompressionArranging Coinshttps://learngolang.net/problems/solve-arranging-coins-problem-in-golang/Mon, 12 Aug 2019 08:59:26 +0000https://learngolang.net/problems/solve-arranging-coins-problem-in-golang/Arranging CoinsFind All Anagrams in a Stringhttps://learngolang.net/problems/solve-find-all-anagrams-in-a-string-problem-in-golang/Mon, 12 Aug 2019 08:58:26 +0000https://learngolang.net/problems/solve-find-all-anagrams-in-a-string-problem-in-golang/Find All Anagrams in a StringPath Sum IIIhttps://learngolang.net/problems/solve-path-sum-iii-problem-in-golang/Mon, 12 Aug 2019 08:57:26 +0000https://learngolang.net/problems/solve-path-sum-iii-problem-in-golang/Path Sum IIINumber of Segments in a Stringhttps://learngolang.net/problems/solve-number-of-segments-in-a-string-problem-in-golang/Mon, 12 Aug 2019 08:56:26 +0000https://learngolang.net/problems/solve-number-of-segments-in-a-string-problem-in-golang/Number of Segments in a StringAdd Stringshttps://learngolang.net/problems/solve-add-strings-problem-in-golang/Mon, 12 Aug 2019 08:55:26 +0000https://learngolang.net/problems/solve-add-strings-problem-in-golang/Add StringsThird Maximum Numberhttps://learngolang.net/problems/solve-third-maximum-number-problem-in-golang/Mon, 12 Aug 2019 08:54:26 +0000https://learngolang.net/problems/solve-third-maximum-number-problem-in-golang/Third Maximum NumberFizz Buzzhttps://learngolang.net/problems/solve-fizz-buzz-problem-in-golang/Mon, 12 Aug 2019 08:53:26 +0000https://learngolang.net/problems/solve-fizz-buzz-problem-in-golang/Fizz BuzzLongest Palindromehttps://learngolang.net/problems/solve-longest-palindrome-problem-in-golang/Mon, 12 Aug 2019 08:52:26 +0000https://learngolang.net/problems/solve-longest-palindrome-problem-in-golang/Longest PalindromeConvert a Number to Hexadecimalhttps://learngolang.net/problems/solve-convert-a-number-to-hexadecimal-problem-in-golang/Mon, 12 Aug 2019 08:51:26 +0000https://learngolang.net/problems/solve-convert-a-number-to-hexadecimal-problem-in-golang/Convert a Number to HexadecimalSum of Left Leaveshttps://learngolang.net/problems/solve-sum-of-left-leaves-problem-in-golang/Mon, 12 Aug 2019 08:50:26 +0000https://learngolang.net/problems/solve-sum-of-left-leaves-problem-in-golang/Sum of Left LeavesBinary Watchhttps://learngolang.net/problems/solve-binary-watch-problem-in-golang/Mon, 12 Aug 2019 08:49:26 +0000https://learngolang.net/problems/solve-binary-watch-problem-in-golang/Binary WatchNth Digithttps://learngolang.net/problems/solve-nth-digit-problem-in-golang/Mon, 12 Aug 2019 08:48:26 +0000https://learngolang.net/problems/solve-nth-digit-problem-in-golang/Nth DigitFind the Differencehttps://learngolang.net/problems/solve-find-the-difference-problem-in-golang/Mon, 12 Aug 2019 08:47:26 +0000https://learngolang.net/problems/solve-find-the-difference-problem-in-golang/Find the DifferenceFirst Unique Character in a Stringhttps://learngolang.net/problems/solve-first-unique-character-in-a-string-problem-in-golang/Mon, 12 Aug 2019 08:46:26 +0000https://learngolang.net/problems/solve-first-unique-character-in-a-string-problem-in-golang/First Unique Character in a StringRansom Notehttps://learngolang.net/problems/solve-ransom-note-problem-in-golang/Mon, 12 Aug 2019 08:45:26 +0000https://learngolang.net/problems/solve-ransom-note-problem-in-golang/Ransom NoteGuess Number Higher or Lowerhttps://learngolang.net/problems/solve-guess-number-higher-or-lower-problem-in-golang/Mon, 12 Aug 2019 08:44:26 +0000https://learngolang.net/problems/solve-guess-number-higher-or-lower-problem-in-golang/Guess Number Higher or LowerSum of Two Integershttps://learngolang.net/problems/solve-sum-of-two-integers-problem-in-golang/Mon, 12 Aug 2019 08:43:26 +0000https://learngolang.net/problems/solve-sum-of-two-integers-problem-in-golang/Sum of Two IntegersValid Perfect Squarehttps://learngolang.net/problems/solve-valid-perfect-square-problem-in-golang/Mon, 12 Aug 2019 08:42:26 +0000https://learngolang.net/problems/solve-valid-perfect-square-problem-in-golang/Valid Perfect SquareIntersection of Two Arrays IIhttps://learngolang.net/problems/solve-intersection-of-two-arrays-ii-problem-in-golang/Mon, 12 Aug 2019 08:41:26 +0000https://learngolang.net/problems/solve-intersection-of-two-arrays-ii-problem-in-golang/Intersection of Two Arrays IIIntersection of Two Arrayshttps://learngolang.net/problems/solve-intersection-of-two-arrays-problem-in-golang/Mon, 12 Aug 2019 08:40:26 +0000https://learngolang.net/problems/solve-intersection-of-two-arrays-problem-in-golang/Intersection of Two ArraysReverse Vowels of a Stringhttps://learngolang.net/problems/solve-reverse-vowels-of-a-string-problem-in-golang/Mon, 12 Aug 2019 08:39:26 +0000https://learngolang.net/problems/solve-reverse-vowels-of-a-string-problem-in-golang/Reverse Vowels of a StringReverse Stringhttps://learngolang.net/problems/solve-reverse-string-problem-in-golang/Mon, 12 Aug 2019 08:38:26 +0000https://learngolang.net/problems/solve-reverse-string-problem-in-golang/Reverse StringPower of Fourhttps://learngolang.net/problems/solve-power-of-four-problem-in-golang/Mon, 12 Aug 2019 08:37:26 +0000https://learngolang.net/problems/solve-power-of-four-problem-in-golang/Power of FourPower of Threehttps://learngolang.net/problems/solve-power-of-three-problem-in-golang/Mon, 12 Aug 2019 08:36:26 +0000https://learngolang.net/problems/solve-power-of-three-problem-in-golang/Power of ThreeRange Sum Query - Immutablehttps://learngolang.net/problems/solve-range-sum-query-immutable-problem-in-golang/Mon, 12 Aug 2019 08:35:26 +0000https://learngolang.net/problems/solve-range-sum-query-immutable-problem-in-golang/Range Sum Query - ImmutableNim Gamehttps://learngolang.net/problems/solve-nim-game-problem-in-golang/Mon, 12 Aug 2019 08:34:26 +0000https://learngolang.net/problems/solve-nim-game-problem-in-golang/Nim GameWord Patternhttps://learngolang.net/problems/solve-word-pattern-problem-in-golang/Mon, 12 Aug 2019 08:33:26 +0000https://learngolang.net/problems/solve-word-pattern-problem-in-golang/Word PatternMove Zeroeshttps://learngolang.net/problems/solve-move-zeroes-problem-in-golang/Mon, 12 Aug 2019 08:32:26 +0000https://learngolang.net/problems/solve-move-zeroes-problem-in-golang/Move ZeroesFirst Bad Versionhttps://learngolang.net/problems/solve-first-bad-version-problem-in-golang/Mon, 12 Aug 2019 08:31:26 +0000https://learngolang.net/problems/solve-first-bad-version-problem-in-golang/First Bad VersionMissing Numberhttps://learngolang.net/problems/solve-missing-number-problem-in-golang/Mon, 12 Aug 2019 08:30:26 +0000https://learngolang.net/problems/solve-missing-number-problem-in-golang/Missing NumberUgly Numberhttps://learngolang.net/problems/solve-ugly-number-problem-in-golang/Mon, 12 Aug 2019 08:29:26 +0000https://learngolang.net/problems/solve-ugly-number-problem-in-golang/Ugly NumberAdd Digitshttps://learngolang.net/problems/solve-add-digits-problem-in-golang/Mon, 12 Aug 2019 08:28:26 +0000https://learngolang.net/problems/solve-add-digits-problem-in-golang/Add DigitsBinary Tree Pathshttps://learngolang.net/problems/solve-binary-tree-paths-problem-in-golang/Mon, 12 Aug 2019 08:27:26 +0000https://learngolang.net/problems/solve-binary-tree-paths-problem-in-golang/Binary Tree PathsValid Anagramhttps://learngolang.net/problems/solve-valid-anagram-problem-in-golang/Mon, 12 Aug 2019 08:26:26 +0000https://learngolang.net/problems/solve-valid-anagram-problem-in-golang/Valid AnagramDelete Node in a Linked Listhttps://learngolang.net/problems/solve-delete-node-in-a-linked-list-problem-in-golang/Mon, 12 Aug 2019 08:25:26 +0000https://learngolang.net/problems/solve-delete-node-in-a-linked-list-problem-in-golang/Delete Node in a Linked ListLowest Common Ancestor of a Binary Search Treehttps://learngolang.net/problems/solve-lowest-common-ancestor-of-a-binary-search-tree-problem-in-golang/Mon, 12 Aug 2019 08:24:26 +0000https://learngolang.net/problems/solve-lowest-common-ancestor-of-a-binary-search-tree-problem-in-golang/Lowest Common Ancestor of a Binary Search TreePalindrome Linked Listhttps://learngolang.net/problems/solve-palindrome-linked-list-problem-in-golang/Mon, 12 Aug 2019 08:23:26 +0000https://learngolang.net/problems/solve-palindrome-linked-list-problem-in-golang/Palindrome Linked ListImplement Queue using Stackshttps://learngolang.net/problems/solve-implement-queue-using-stacks-problem-in-golang/Mon, 12 Aug 2019 08:22:26 +0000https://learngolang.net/problems/solve-implement-queue-using-stacks-problem-in-golang/Implement Queue using StacksPower of Twohttps://learngolang.net/problems/solve-power-of-two-problem-in-golang/Mon, 12 Aug 2019 08:21:26 +0000https://learngolang.net/problems/solve-power-of-two-problem-in-golang/Power of TwoInvert Binary Treehttps://learngolang.net/problems/solve-invert-binary-tree-problem-in-golang/Mon, 12 Aug 2019 08:20:26 +0000https://learngolang.net/problems/solve-invert-binary-tree-problem-in-golang/Invert Binary TreeImplement Stack using Queueshttps://learngolang.net/problems/solve-implement-stack-using-queues-problem-in-golang/Mon, 12 Aug 2019 08:19:26 +0000https://learngolang.net/problems/solve-implement-stack-using-queues-problem-in-golang/Implement Stack using QueuesContains Duplicate IIhttps://learngolang.net/problems/solve-contains-duplicate-ii-problem-in-golang/Mon, 12 Aug 2019 08:18:26 +0000https://learngolang.net/problems/solve-contains-duplicate-ii-problem-in-golang/Contains Duplicate IIContains Duplicatehttps://learngolang.net/problems/solve-contains-duplicate-problem-in-golang/Mon, 12 Aug 2019 08:17:26 +0000https://learngolang.net/problems/solve-contains-duplicate-problem-in-golang/Contains DuplicateReverse Linked Listhttps://learngolang.net/problems/solve-reverse-linked-list-problem-in-golang/Mon, 12 Aug 2019 08:16:26 +0000https://learngolang.net/problems/solve-reverse-linked-list-problem-in-golang/Reverse Linked ListIsomorphic Stringshttps://learngolang.net/problems/solve-isomorphic-strings-problem-in-golang/Mon, 12 Aug 2019 08:15:26 +0000https://learngolang.net/problems/solve-isomorphic-strings-problem-in-golang/Isomorphic StringsCount Primeshttps://learngolang.net/problems/solve-count-primes-problem-in-golang/Mon, 12 Aug 2019 08:14:26 +0000https://learngolang.net/problems/solve-count-primes-problem-in-golang/Count PrimesRemove Linked List Elementshttps://learngolang.net/problems/solve-remove-linked-list-elements-problem-in-golang/Mon, 12 Aug 2019 08:13:26 +0000https://learngolang.net/problems/solve-remove-linked-list-elements-problem-in-golang/Remove Linked List ElementsHappy Numberhttps://learngolang.net/problems/solve-happy-number-problem-in-golang/Mon, 12 Aug 2019 08:12:26 +0000https://learngolang.net/problems/solve-happy-number-problem-in-golang/Happy NumberHouse Robberhttps://learngolang.net/problems/solve-house-robber-problem-in-golang/Mon, 12 Aug 2019 08:11:26 +0000https://learngolang.net/problems/solve-house-robber-problem-in-golang/House RobberRising Temperaturehttps://learngolang.net/problems/solve-rising-temperature-problem-in-golang/Mon, 12 Aug 2019 08:10:26 +0000https://learngolang.net/problems/solve-rising-temperature-problem-in-golang/Rising TemperatureDelete Duplicate Emailshttps://learngolang.net/problems/solve-delete-duplicate-emails-problem-in-golang/Mon, 12 Aug 2019 08:09:26 +0000https://learngolang.net/problems/solve-delete-duplicate-emails-problem-in-golang/Delete Duplicate EmailsTenth Linehttps://learngolang.net/problems/solve-tenth-line-problem-in-golang/Mon, 12 Aug 2019 08:08:26 +0000https://learngolang.net/problems/solve-tenth-line-problem-in-golang/Tenth LineValid Phone Numbershttps://learngolang.net/problems/solve-valid-phone-numbers-problem-in-golang/Mon, 12 Aug 2019 08:07:26 +0000https://learngolang.net/problems/solve-valid-phone-numbers-problem-in-golang/Valid Phone NumbersNumber of 1 Bitshttps://learngolang.net/problems/solve-number-of-1-bits-problem-in-golang/Mon, 12 Aug 2019 08:06:26 +0000https://learngolang.net/problems/solve-number-of-1-bits-problem-in-golang/Number of 1 BitsReverse Bitshttps://learngolang.net/problems/solve-reverse-bits-problem-in-golang/Mon, 12 Aug 2019 08:05:26 +0000https://learngolang.net/problems/solve-reverse-bits-problem-in-golang/Reverse BitsRotate Arrayhttps://learngolang.net/problems/solve-rotate-array-problem-in-golang/Mon, 12 Aug 2019 08:04:26 +0000https://learngolang.net/problems/solve-rotate-array-problem-in-golang/Rotate ArrayCustomers Who Never Orderhttps://learngolang.net/problems/solve-customers-who-never-order-problem-in-golang/Mon, 12 Aug 2019 08:03:26 +0000https://learngolang.net/problems/solve-customers-who-never-order-problem-in-golang/Customers Who Never OrderDuplicate Emailshttps://learngolang.net/problems/solve-duplicate-emails-problem-in-golang/Mon, 12 Aug 2019 08:02:26 +0000https://learngolang.net/problems/solve-duplicate-emails-problem-in-golang/Duplicate EmailsEmployees Earning More Than Their Managershttps://learngolang.net/problems/solve-employees-earning-more-than-their-managers-problem-in-golang/Mon, 12 Aug 2019 08:01:26 +0000https://learngolang.net/problems/solve-employees-earning-more-than-their-managers-problem-in-golang/Employees Earning More Than Their ManagersSecond Highest Salaryhttps://learngolang.net/problems/solve-second-highest-salary-problem-in-golang/Mon, 12 Aug 2019 08:00:26 +0000https://learngolang.net/problems/solve-second-highest-salary-problem-in-golang/Second Highest SalaryCombine Two Tableshttps://learngolang.net/problems/solve-combine-two-tables-problem-in-golang/Mon, 12 Aug 2019 07:59:26 +0000https://learngolang.net/problems/solve-combine-two-tables-problem-in-golang/Combine Two TablesFactorial Trailing Zeroeshttps://learngolang.net/problems/solve-factorial-trailing-zeroes-problem-in-golang/Mon, 12 Aug 2019 07:58:26 +0000https://learngolang.net/problems/solve-factorial-trailing-zeroes-problem-in-golang/Factorial Trailing ZeroesExcel Sheet Column Numberhttps://learngolang.net/problems/solve-excel-sheet-column-number-problem-in-golang/Mon, 12 Aug 2019 07:57:26 +0000https://learngolang.net/problems/solve-excel-sheet-column-number-problem-in-golang/Excel Sheet Column NumberMajority Elementhttps://learngolang.net/problems/solve-majority-element-problem-in-golang/Mon, 12 Aug 2019 07:56:26 +0000https://learngolang.net/problems/solve-majority-element-problem-in-golang/Majority ElementExcel Sheet Column Titlehttps://learngolang.net/problems/solve-excel-sheet-column-title-problem-in-golang/Mon, 12 Aug 2019 07:55:26 +0000https://learngolang.net/problems/solve-excel-sheet-column-title-problem-in-golang/Excel Sheet Column TitleTwo Sum II - Input array is sortedhttps://learngolang.net/problems/solve-two-sum-ii-input-array-is-sorted-problem-in-golang/Mon, 12 Aug 2019 07:54:26 +0000https://learngolang.net/problems/solve-two-sum-ii-input-array-is-sorted-problem-in-golang/Two Sum II - Input array is sortedIntersection of Two Linked Listshttps://learngolang.net/problems/solve-intersection-of-two-linked-lists-problem-in-golang/Mon, 12 Aug 2019 07:53:26 +0000https://learngolang.net/problems/solve-intersection-of-two-linked-lists-problem-in-golang/Intersection of Two Linked ListsMin Stackhttps://learngolang.net/problems/solve-min-stack-problem-in-golang/Mon, 12 Aug 2019 07:52:26 +0000https://learngolang.net/problems/solve-min-stack-problem-in-golang/Min StackLinked List Cyclehttps://learngolang.net/problems/solve-linked-list-cycle-problem-in-golang/Mon, 12 Aug 2019 07:51:26 +0000https://learngolang.net/problems/solve-linked-list-cycle-problem-in-golang/Linked List CycleSingle Numberhttps://learngolang.net/problems/solve-single-number-problem-in-golang/Mon, 12 Aug 2019 07:50:26 +0000https://learngolang.net/problems/solve-single-number-problem-in-golang/Single NumberValid Palindromehttps://learngolang.net/problems/solve-valid-palindrome-problem-in-golang/Mon, 12 Aug 2019 07:49:26 +0000https://learngolang.net/problems/solve-valid-palindrome-problem-in-golang/Valid PalindromeBest Time to Buy and Sell Stock IIhttps://learngolang.net/problems/solve-best-time-to-buy-and-sell-stock-ii-problem-in-golang/Mon, 12 Aug 2019 07:48:26 +0000https://learngolang.net/problems/solve-best-time-to-buy-and-sell-stock-ii-problem-in-golang/Best Time to Buy and Sell Stock IIBest Time to Buy and Sell Stockhttps://learngolang.net/problems/solve-best-time-to-buy-and-sell-stock-problem-in-golang/Mon, 12 Aug 2019 07:47:26 +0000https://learngolang.net/problems/solve-best-time-to-buy-and-sell-stock-problem-in-golang/Best Time to Buy and Sell StockPascal's Triangle IIhttps://learngolang.net/problems/solve-pascals-triangle-ii-problem-in-golang/Mon, 12 Aug 2019 07:46:26 +0000https://learngolang.net/problems/solve-pascals-triangle-ii-problem-in-golang/Pascal's Triangle IIPascal's Trianglehttps://learngolang.net/problems/solve-pascals-triangle-problem-in-golang/Mon, 12 Aug 2019 07:45:26 +0000https://learngolang.net/problems/solve-pascals-triangle-problem-in-golang/Pascal's TrianglePath Sumhttps://learngolang.net/problems/solve-path-sum-problem-in-golang/Mon, 12 Aug 2019 07:44:26 +0000https://learngolang.net/problems/solve-path-sum-problem-in-golang/Path SumMinimum Depth of Binary Treehttps://learngolang.net/problems/solve-minimum-depth-of-binary-tree-problem-in-golang/Mon, 12 Aug 2019 07:43:26 +0000https://learngolang.net/problems/solve-minimum-depth-of-binary-tree-problem-in-golang/Minimum Depth of Binary TreeBalanced Binary Treehttps://learngolang.net/problems/solve-balanced-binary-tree-problem-in-golang/Mon, 12 Aug 2019 07:42:26 +0000https://learngolang.net/problems/solve-balanced-binary-tree-problem-in-golang/Balanced Binary TreeConvert Sorted Array to Binary Search Treehttps://learngolang.net/problems/solve-convert-sorted-array-to-binary-search-tree-problem-in-golang/Mon, 12 Aug 2019 07:41:26 +0000https://learngolang.net/problems/solve-convert-sorted-array-to-binary-search-tree-problem-in-golang/Convert Sorted Array to Binary Search TreeBinary Tree Level Order Traversal IIhttps://learngolang.net/problems/solve-binary-tree-level-order-traversal-ii-problem-in-golang/Mon, 12 Aug 2019 07:40:26 +0000https://learngolang.net/problems/solve-binary-tree-level-order-traversal-ii-problem-in-golang/Binary Tree Level Order Traversal IIMaximum Depth of Binary Treehttps://learngolang.net/problems/solve-maximum-depth-of-binary-tree-problem-in-golang/Mon, 12 Aug 2019 07:39:26 +0000https://learngolang.net/problems/solve-maximum-depth-of-binary-tree-problem-in-golang/Maximum Depth of Binary TreeSymmetric Treehttps://learngolang.net/problems/solve-symmetric-tree-problem-in-golang/Mon, 12 Aug 2019 07:38:26 +0000https://learngolang.net/problems/solve-symmetric-tree-problem-in-golang/Symmetric TreeSame Treehttps://learngolang.net/problems/solve-same-tree-problem-in-golang/Mon, 12 Aug 2019 07:37:26 +0000https://learngolang.net/problems/solve-same-tree-problem-in-golang/Same TreeMerge Sorted Arrayhttps://learngolang.net/problems/solve-merge-sorted-array-problem-in-golang/Mon, 12 Aug 2019 07:36:26 +0000https://learngolang.net/problems/solve-merge-sorted-array-problem-in-golang/Merge Sorted ArrayRemove Duplicates from Sorted Listhttps://learngolang.net/problems/solve-remove-duplicates-from-sorted-list-problem-in-golang/Mon, 12 Aug 2019 07:35:26 +0000https://learngolang.net/problems/solve-remove-duplicates-from-sorted-list-problem-in-golang/Remove Duplicates from Sorted ListClimbing Stairshttps://learngolang.net/problems/solve-climbing-stairs-problem-in-golang/Mon, 12 Aug 2019 07:34:26 +0000https://learngolang.net/problems/solve-climbing-stairs-problem-in-golang/Climbing StairsSqrt(x)https://learngolang.net/problems/solve-sqrtx-problem-in-golang/Mon, 12 Aug 2019 07:33:26 +0000https://learngolang.net/problems/solve-sqrtx-problem-in-golang/Sqrt(x)Add Binaryhttps://learngolang.net/problems/solve-add-binary-problem-in-golang/Mon, 12 Aug 2019 07:32:26 +0000https://learngolang.net/problems/solve-add-binary-problem-in-golang/Add BinaryPlus Onehttps://learngolang.net/problems/solve-plus-one-problem-in-golang/Mon, 12 Aug 2019 07:31:26 +0000https://learngolang.net/problems/solve-plus-one-problem-in-golang/Plus OneLength of Last Wordhttps://learngolang.net/problems/solve-length-of-last-word-problem-in-golang/Mon, 12 Aug 2019 07:30:26 +0000https://learngolang.net/problems/solve-length-of-last-word-problem-in-golang/Length of Last WordMaximum Subarrayhttps://learngolang.net/problems/solve-maximum-subarray-problem-in-golang/Mon, 12 Aug 2019 07:29:26 +0000https://learngolang.net/problems/solve-maximum-subarray-problem-in-golang/Maximum SubarrayCount and Sayhttps://learngolang.net/problems/solve-count-and-say-problem-in-golang/Mon, 12 Aug 2019 07:28:26 +0000https://learngolang.net/problems/solve-count-and-say-problem-in-golang/Count and SaySearch Insert Positionhttps://learngolang.net/problems/solve-search-insert-position-problem-in-golang/Mon, 12 Aug 2019 07:27:26 +0000https://learngolang.net/problems/solve-search-insert-position-problem-in-golang/Search Insert PositionImplement strStr()https://learngolang.net/problems/solve-implement-strstr-problem-in-golang/Mon, 12 Aug 2019 07:26:26 +0000https://learngolang.net/problems/solve-implement-strstr-problem-in-golang/Implement strStr()Remove Duplicates from Sorted Arrayhttps://learngolang.net/problems/solve-remove-duplicates-from-sorted-array-problem-in-golang/Mon, 12 Aug 2019 07:24:26 +0000https://learngolang.net/problems/solve-remove-duplicates-from-sorted-array-problem-in-golang/Remove Duplicates from Sorted ArrayLongest Common Prefixhttps://learngolang.net/problems/solve-longest-common-prefix-problem-in-golang/Mon, 12 Aug 2019 07:21:26 +0000https://learngolang.net/problems/solve-longest-common-prefix-problem-in-golang/Longest Common PrefixPalindrome Numberhttps://learngolang.net/problems/solve-palindrome-number-problem-in-golang/Mon, 12 Aug 2019 07:19:26 +0000https://learngolang.net/problems/solve-palindrome-number-problem-in-golang/Palindrome NumberPrint Look and Say Sequence in Gohttps://learngolang.net/tutorials/print-look-and-say-sequence-in-go/Sun, 05 May 2019 23:17:54 +0100https://learngolang.net/tutorials/print-look-and-say-sequence-in-go/Look-and-say sequence In mathematics, the look-and-say sequence is the sequence of integers beginning as follows:
1, 11, 21, 1211, 111221, 312211, 13112221, 1113213211, ...
To generate a member of the sequence from the previous member, read off the digits of the previous member, counting the number of digits in groups of the same digit. For example:
1 is read off as “one 1” or 11. 11 is read off as “two 1s” or 21.How to convert integer to english words in gohttps://learngolang.net/tutorials/how-to-convert-integer-to-english-words-in-golang/Fri, 26 Apr 2019 11:21:19 +0100https://learngolang.net/tutorials/how-to-convert-integer-to-english-words-in-golang/The following code converts number to their english spelling.
package main import ( "fmt" "math" ) func main() { for i := 0; i <= 10000; i++ { fmt.Println(i, spell(i)) } // i := 88 // fmt.Println(i, spell(i)) } func pow(i int, p int) int { return int(math.Pow(1000, float64(p))) } func spell(n int) string { to19 := []string{"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", ",Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"} tens := []string{"Twenty", "Thirty", "Forty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"} if n == 0 { return "" } if n < 20 { return to19[n-1] } if n < 100 { return tens[n/10-2] + " " + spell(n%10) } if n < 1000 { return to19[n/100-1] + " Hundred " + spell(n%100) } for idx, w := range []string{"Thousand", "Million", "Billion"} { p := idx + 1 if n < pow(1000, (p+1)) { return spell(n/pow(1000, p)) + " " + w + " " + spell(n%pow(1000, p)) } } return "error" }How to solve ransom note problem in gohttps://learngolang.net/tutorials/ransom-note-problem/Sun, 21 Apr 2019 11:21:19 +0100https://learngolang.net/tutorials/ransom-note-problem/Here is a solution using an array for solving ransom note problem in golang.
package main import "fmt" func main() { note := buildCharFrequencyTable("ma said") magzine := buildCharFrequencyTable("aaimmds") fmt.Println(canBuildNote(note, magzine)) } func buildCharFrequencyTable(str string) []int { counter := []int{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, } for _, char := range str { c := int(char - 'a') if c > 0 { counter[c]++ } } return counter } func canBuildNote(note []int, magzine []int) bool { for i := 0; i < len(magzine); i++ { if note[i] > magzine[i] { return false } } return true } Here is another solution to this problem using a hashtableHow to convert number to roman numeralshttps://learngolang.net/tutorials/how-to-convert-numbers-to-roman-numerals-in-golang/Mon, 15 Apr 2019 11:21:19 +0100https://learngolang.net/tutorials/how-to-convert-numbers-to-roman-numerals-in-golang/Summary Converting integers to markdown is fairly simple.
Here are 13 roman numerals and their decimal equivalent.
Decimal Roman 1 I 4 IV 5 V 9 IX 10 X 40 XL 50 L 90 XC 100 C 400 CD 500 D 900 CM 1000 M The process is as follows, for any given decimal number X:Count number of binary search tree created for array of size nhttps://learngolang.net/tutorials/count-number-of-binary-search-tree-created-for-array-of-size-n/Fri, 09 Nov 2018 21:47:32 +0000https://learngolang.net/tutorials/count-number-of-binary-search-tree-created-for-array-of-size-n/This problem is an example of “catalan Numbers problem”
The Question is as follows Count number of binary search tree created for array of size n
Solution in golang package main import ( "fmt" ) func main() { for i := 0; i < 20; i++ { fmt.Println(i, countTreesRec(i)) } } func countTreesRec(numKeys int) int { if numKeys <= 1 { return 1 } else { sum := 0 for root := 1; root <= numKeys; root++ { left := countTreesRec(root - 1) right := countTreesRec(numKeys - root) sum += left * right } return sum } }Find Nth Catalan Number in Golanghttps://learngolang.net/tutorials/find-nth-catalan-number-in-golang/Fri, 09 Nov 2018 20:52:48 +0000https://learngolang.net/tutorials/find-nth-catalan-number-in-golang/Compute n'th Catalan number In combinatorial mathematics, the Catalan numbers form a sequence of natural numbers that occur in various counting problems, often involving recursively-defined objects. They are named after the Belgian mathematician EugĂ¨ne Charles Catalan.
They can be computed using this formula:
C(2n, n)/(n + 1)
Read more about them here
Recursive code in go func main() { for i := 0; i < 20; i++ { fmt.Println(i, catalan(i)) } //0 1 //1 1 //2 2 //3 5 //4 14 //5 42 //6 132 //7 429 //8 1430 //9 4862 //10 16796 //11 58786 //12 208012 //13 742900 //14 2674440 //15 9694845 //16 35357670 //17 129644790 //18 477638700 //19 1767263190 } // catalan(n) is sum of catalan(i)*catalan(n-i-1) func catalan(n int) int { // Base case if n <= 1 { return 1 } res := 0 for i := 0; i < n; i++ { res += catalan(i) * catalan(n-i-1) } return res } Using Binomial Coefficient We can also use the below formula to find nth catalan number in O(n) time.How to Remove Duplicates From Sorted Array in Gohttps://learngolang.net/tutorials/how-to-remove-duplicates-from-sorted-array-in-go/Fri, 09 Nov 2018 20:02:06 +0000https://learngolang.net/tutorials/how-to-remove-duplicates-from-sorted-array-in-go/Problem Statement Given a sorted array of numbers, remove the duplicates in-place such that each element appear only once and return the new length.
Example 1 Given nums = [1,1,2],
Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively.
It doesn't matter what you leave beyond the returned length.
Example 2 Given nums = [0,0,1,1,1,2,2,3,3,4],How to Remove All Files in a Directory in Gohttps://learngolang.net/tutorials/how-to-remove-all-files-in-a-directory-in-go/Sun, 04 Nov 2018 12:45:25 +0000https://learngolang.net/tutorials/how-to-remove-all-files-in-a-directory-in-go/Built in Options There, always is a need to delete all files in a directory in golang.
os.RemoveAll function is used a lot. The documentation says,
RemoveAll removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error).
Here is a quick example func main() { err := os.RemoveAll("files") fmt.How to copy a file in gohttps://learngolang.net/tutorials/how-to-copy-file-in-go/Fri, 12 Oct 2018 21:21:19 +0100https://learngolang.net/tutorials/how-to-copy-file-in-go/Here is a snippet, which copies a file from source to destination.
package main import ( "io" "log" "os" ) func main() { // Open original file source, err := os.Open("foo.txt") if err != nil { log.Fatal(err) } defer source.Close() // Create new file destination, err := os.Create("bar.txt") if err != nil { log.Fatal(err) } defer destination.Close() // Copy the bytes to destination from source bytesWritten, err := io.How to truncate a file in gohttps://learngolang.net/tutorials/how-to-truncate-a-file-in-go/Fri, 05 Oct 2018 22:33:21 +0100https://learngolang.net/tutorials/how-to-truncate-a-file-in-go/Truncating a file is very rare but incase yer wondering how to do it in go, here is a snippet.
This code will truncate a file to 50 bytes. If the file is less than 50 bytes the original contents will remain at the beginning, and the rest of the space is filled will null bytes.
If it is over 50 bytes, then everything after 50 bytes will be lost.How to append in a file in gohttps://learngolang.net/tutorials/how-to-append-in-a-file-in-go/Fri, 05 Oct 2018 22:20:24 +0100https://learngolang.net/tutorials/how-to-append-in-a-file-in-go/Here is a snippet which shows how to append data in a file in golang.
We will use os.OpenFile with os._APPEND flag.
package main import ( "fmt" "os" ) func main() { for i := 0; i < 10; i++ { append(fmt.Sprintf("line %d \n", i)) } } func append(text string) { f, err := os.OpenFile("myfile.txt", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) if err != nil { panic(err) } defer f.Close() f.WriteString(text) } Here is a handly list of other flags which can be combined togther and usedHow to change permission, timestamps and ownership of a file in gohttps://learngolang.net/tutorials/how-to-change-permission-timestamps-and-ownership-of-a-file-in-go/Fri, 05 Oct 2018 21:21:19 +0100https://learngolang.net/tutorials/how-to-change-permission-timestamps-and-ownership-of-a-file-in-go/Change Permission Package os, has a handy Chmod method, just like the command line interface in Linux .
package main import ( "fmt" "os" ) func main() { err := os.Chmod("myfile.txt", 0777) if err != nil { fmt.Println(err) } } Change Ownership There is also a Chown
package main import ( "fmt" "os" ) func main() { err := os.Chown("myFile.txt", os.Getuid(), os.Getgid()) if err != nil { fmt.Println(err) } } Change timestamps As well as a ChtimesHow to write a file in gohttps://learngolang.net/tutorials/how-to-write-a-file-in-go/Fri, 05 Oct 2018 21:21:19 +0100https://learngolang.net/tutorials/how-to-write-a-file-in-go/The quickest way to write a file with some bytes is to use ioutil.WriteFile
package main import ( "fmt" "io/ioutil" ) func main() { err := ioutil.WriteFile("somefile", []byte("foo\n"), 0644) if err != nil { fmt.Println("error while writing file") } } A more explicit way could be to use os.Create
package main import ( "fmt" "os" ) func main() { f, err := os.Create("foo.dat") if err != nil { fmt.Println("error while creating file") } defer f.How to create a file in gohttps://learngolang.net/tutorials/how-to-create-a-file-in-go/Fri, 05 Oct 2018 10:11:33 +0100https://learngolang.net/tutorials/how-to-create-a-file-in-go/Go lets you easily create and write a new file.
Here is an example using create from os package.
package main import "os" func main() { //create a file f, err := os.Create("foo") if err != nil { panic(err) } //make sure it closes. defer f.Close() } os.Create creates a file with default mode 0666 , and default file descriptor as O_RDWR .
Here is another explicit exampleHow to check file permissions in gohttps://learngolang.net/tutorials/how-to-check-file-permissions-in-go/Tue, 02 Oct 2018 22:43:02 +0100https://learngolang.net/tutorials/how-to-check-file-permissions-in-go/package main import ( "fmt" "os" ) func main() { var perms = []int{os.O_RDONLY, os.O_WRONLY} for perm := range perms { file, err := os.OpenFile("myFile.txt", perm, 0666) if err != nil { if os.IsNotExist(err) { panic("File not found.") } if os.IsPermission(err) { fmt.Println(fmt.Sprintf("Error: %v permission denied.", perm)) } } file.Close() } }How to delete a file in gohttps://learngolang.net/tutorials/how-to-delete-a-file-in-go/Tue, 02 Oct 2018 22:43:02 +0100https://learngolang.net/tutorials/how-to-delete-a-file-in-go/The os package has os.Remove function, which is used to delete a file as shown below.
package main import ( "fmt" "os" ) func main() { err := os.Remove("test.txt") if err != nil { fmt.Println(err) } }How to get fileinfo in gohttps://learngolang.net/tutorials/how-to-get-file-info-in-go/Tue, 02 Oct 2018 22:43:02 +0100https://learngolang.net/tutorials/how-to-get-file-info-in-go/os.stat is used in golang to get all the meta information about a file.
os.stat will return a fileinfo object or an error if the file is not found.
package main import ( "fmt" "log" "os" ) func main() { fileInfo, err := os.Stat("myfile.txt") if err != nil { log.Fatal(err) } fmt.Println("File name:", fileInfo.Name()) fmt.Println("Size in bytes:", fileInfo.Size()) fmt.Println("Permissions:", fileInfo.Mode()) fmt.Println("Last modified:", fileInfo.ModTime()) fmt.Println("Is Directory: ", fileInfo.IsDir()) fmt.Printf("System interface type: %T\n", fileInfo.Linking and symlink a file in gohttps://learngolang.net/tutorials/linking-and-symlink-files-using-go/Tue, 02 Oct 2018 21:21:19 +0100https://learngolang.net/tutorials/linking-and-symlink-files-using-go/A Link in Linux is just a pointer to a file or a directory.
A hardlink is a new pointer to the same file, hard links actually have file contents.
A softlink does not point directly to the file, and is only a reference. softlinks are also called symlink
Hard Linking in golang package main import ( "fmt" "os" ) func main() { err := os.Link("original.txt", "hardlink.txt") if err != nil { fmt.How to check if a file exists in gohttps://learngolang.net/tutorials/how-to-check-if-a-file-exists-in-go/Mon, 01 Oct 2018 18:02:05 +0100https://learngolang.net/tutorials/how-to-check-if-a-file-exists-in-go/Here is a quick snippet to check if a file exists in go
package main import ( "fmt" "os" ) func main() { if _, err := os.Stat("somefile"); os.IsNotExist(err) { fmt.Println("path to \"somefile\" does not exist") } } In an edge case a file might disappear between an exist check and open
So, it might be a good idea to always open a file and check for returned err.
If the file does not exist, it can be detected by os.How to rename and move a file in gohttps://learngolang.net/tutorials/how-to-rename-and-move-a-file-in-go/Sun, 02 Sep 2018 22:43:02 +0100https://learngolang.net/tutorials/how-to-rename-and-move-a-file-in-go/To rename a file there is os.Rename method, which takes original name and the new name.
package main import ( "fmt" "os" ) func main() { oldname := "file1.txt" newname := "file2.txt" err := os.Rename(oldname, newname) if err != nil { fmt.Println(err) } } The same method can be used to move the file as well.
package main import ( "fmt" "os" ) func main() { originalPath := "file1.txt" newPath := "/some/other/folder/file2.