{"id":862,"date":"2026-10-11T09:00:00","date_gmt":"2026-10-11T03:30:00","guid":{"rendered":"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/"},"modified":"2026-11-29T01:29:23","modified_gmt":"2026-11-28T19:59:23","slug":"go-coding-interview-programs","status":"publish","type":"post","link":"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/","title":{"rendered":"Go Coding Interview Programs: LRU, Sliding Window and DP"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Go coding interview programs are the problems companies give you in a live coding round, where you must write correct code, explain it and state its speed. In this post, you will write fourteen of the most asked problems with their exact output and the logic explained in comments, covering an LRU cache, sliding window, two pointers, intervals and dynamic programming.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This post closes the Go Programs series, so it uses ideas from every level. Make sure you are comfortable with the <a href=\"https:\/\/smitabharat.com\/blog\/go-map-programs\/\">Go map programs<\/a>, <a href=\"https:\/\/smitabharat.com\/blog\/go-linked-list-programs\/\">Go linked list programs<\/a> and <a href=\"https:\/\/smitabharat.com\/blog\/go-sorting-programs\/\">Go sorting programs<\/a>. All programs were tested on Go 1.27.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What are Go Coding Interview Programs?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Go coding interview programs are short, self-contained problems with a clear input and output. The interviewer cares about three things: a correct answer, a clean explanation and a good time and space complexity.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Think of a driving test. Driving from A to B is not enough. The examiner also watches how you check mirrors, signal and park. In an interview, how you reach the answer matters as much as the answer.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Go Coding Interview Programs Matter<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Most product companies still run at least one data structure round, even for backend roles.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Patterns repeat:<\/strong> about ten patterns cover most questions you will see.<\/li>\n\n\n<li><strong>Go is a good fit:<\/strong> slices, maps and simple syntax keep solutions short.<\/li>\n\n\n<li><strong>Real work:<\/strong> caches, rate limits and interval merges appear in real backend code.<\/li>\n\n\n<li><strong>Confidence:<\/strong> practising the common set makes new problems feel familiar.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">How to Solve Go Coding Interview Programs<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Use the same five steps for every problem. First, repeat the problem and ask about edge cases. Next, write a slow but correct idea. Then find the pattern that makes it faster. After that, write the code while you talk. Finally, test it with a small example and state the Big O.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-diagram-1-1024x640.png\" alt=\"Go coding interview programs diagram showing the five steps to solve a coding problem\" class=\"wp-image-860\" srcset=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-diagram-1-1024x640.png 1024w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-diagram-1-300x188.png 300w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-diagram-1-768x480.png 768w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-diagram-1-1536x960.png 1536w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-diagram-1-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Clarify, start simple, find the pattern, code while talking, then test and state the complexity.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The table below maps common question words to the pattern that usually solves them.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>If the question says<\/th><th>Try this pattern<\/th><th>Example in this post<\/th><\/tr><\/thead><tbody><tr><td>Longest or shortest substring<\/td><td>Sliding window<\/td><td>Program 2<\/td><\/tr><tr><td>Sorted array, pair or triple<\/td><td>Two pointers<\/td><td>Programs 7 to 9<\/td><\/tr><tr><td>Overlapping ranges<\/td><td>Sort, then merge<\/td><td>Program 5<\/td><\/tr><tr><td>Number of ways or minimum cost<\/td><td>Dynamic programming<\/td><td>Programs 10 to 12<\/td><\/tr><tr><td>Get and put in O(1)<\/td><td>Map plus linked list<\/td><td>Program 1<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Design Go Coding Interview Programs<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These first Go coding interview programs ask you to design a small data structure, which is common in backend rounds.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Program 1: LRU Cache<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport (\n    \"container\/list\"\n    \"fmt\"\n)\n\n\/\/ entry is one key and value stored in the cache.\ntype entry struct {\n    key, value int\n}\n\n\/\/ LRU keeps the most recently used items at the front of a list.\n\/\/ The map finds a list element in O(1), the list reorders in O(1).\ntype LRU struct {\n    capacity int\n    order    *list.List            \/\/ a doubly linked list from the standard library\n    items    map[int]*list.Element \/\/ key -&gt; its element in the list\n}\n\n\/\/ NewLRU creates an empty cache that can hold capacity items.\nfunc NewLRU(capacity int) *LRU {\n    return &amp;LRU{capacity: capacity, order: list.New(), items: map[int]*list.Element{}}\n}\n\n\/\/ Get returns the value for key, or -1 if the key is not in the cache.\nfunc (cache *LRU) Get(key int) int {\n    element, ok := cache.items[key] \/\/ ok is true if the key was found\n    if !ok {\n        return -1\n    }\n    cache.order.MoveToFront(element) \/\/ just used, so it becomes the newest\n    \/\/ element.Value has type any, so .(*entry) turns it back into our entry\n    return element.Value.(*entry).value\n}\n\n\/\/ Put adds or updates a key. When full, it removes the oldest item first.\nfunc (cache *LRU) Put(key, value int) {\n    element, ok := cache.items[key]\n    if ok {\n        element.Value.(*entry).value = value \/\/ key exists: update it\n        cache.order.MoveToFront(element)\n        return\n    }\n    if cache.order.Len() == cache.capacity {\n        oldest := cache.order.Back() \/\/ least recently used is at the back\n        cache.order.Remove(oldest)\n        delete(cache.items, oldest.Value.(*entry).key) \/\/ delete removes a map key\n    }\n    cache.items[key] = cache.order.PushFront(&amp;entry{key, value})\n}\n\nfunc main() {\n    cache := NewLRU(2)\n    cache.Put(1, 100)\n    cache.Put(2, 200)\n    fmt.Println(cache.Get(1)) \/\/ 1 is now the newest\n    cache.Put(3, 300)         \/\/ full: removes 2, the oldest\n    fmt.Println(cache.Get(2), cache.Get(3), cache.Get(1))\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>100\n-1 300 100<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The map jumps straight to an item, and the list keeps the items in order of use. Each <code>Get<\/code> moves the item to the front, so the back always holds the oldest one. Every <code>Get<\/code> and <code>Put<\/code> is O(1), and LRU cache is one of the most asked Go coding interview programs. The entry stores its own key, so when we remove the oldest list element we know which map key to delete too.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Program 2: Longest Substring Without Repeating Characters<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\n\/\/ longest uses a sliding window [left, right] with no repeated bytes.\nfunc longest(text string) int {\n    lastSeen := map[byte]int{} \/\/ character -&gt; last index where we saw it\n    best := 0\n    left := 0\n    for right := 0; right &lt; len(text); right++ {\n        char := text[right]\n        lastIndex, found := lastSeen[char] \/\/ found is true if we saw char before\n        if found &amp;&amp; lastIndex &gt;= left {\n            left = lastIndex + 1 \/\/ jump past the old copy of char\n        }\n        lastSeen[char] = right\n        best = max(best, right-left+1) \/\/ window size is right-left+1\n    }\n    return best\n}\n\nfunc main() {\n    for _, text := range []string{\"abcabcbb\", \"bbbbb\", \"pwwkew\", \"\"} {\n        fmt.Printf(\"%q -&gt; %d\\n\", text, longest(text)) \/\/ %q prints the text in quotes\n    }\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>\"abcabcbb\" -&gt; 3\n\"bbbbb\" -&gt; 1\n\"pwwkew\" -&gt; 3\n\"\" -&gt; 0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>right<\/code> index grows the window one character at a time. If that character is already inside the window, <code>left<\/code> jumps just past its old copy. The window only moves forward, so each character is checked a fixed number of times. That makes it O(n) instead of checking every substring.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Program 3: Maximum Subarray Sum (Kadane&#8217;s Method)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\n\/\/ maxSubarray keeps the best sum ending here, and the best sum seen so far.\nfunc maxSubarray(numbers []int) int {\n    current := numbers[0]\n    best := numbers[0]\n    for _, number := range numbers[1:] { \/\/ [1:] skips the first item\n        \/\/ either start fresh at number, or add it to the old run\n        current = max(number, current+number)\n        best = max(best, current)\n    }\n    return best\n}\n\nfunc main() {\n    fmt.Println(maxSubarray([]int{-2, 1, -3, 4, -1, 2, 1, -5, 4}))\n    fmt.Println(maxSubarray([]int{-3, -1, -2}))\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>6\n-1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><code>current<\/code> is the best sum of a run that ends at this number. <code>best<\/code> remembers the biggest <code>current<\/code> you have seen. The best run is <code>[4 -1 2 1]<\/code>. If a running sum turns worse than the current value alone, we drop it and start again, which is the whole trick.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Array Go Coding Interview Programs<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These Go coding interview programs work on arrays, using maps, sorting, prefix products and two pointers.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Program 4: Two Sum with a Map<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\n\/\/ twoSum returns the positions of two numbers that add up to target.\nfunc twoSum(numbers []int, target int) (int, int) {\n    seen := map[int]int{} \/\/ number -&gt; the index where we saw it\n    for index, number := range numbers {\n        need := target - number           \/\/ the partner this number needs\n        partnerIndex, found := seen[need] \/\/ found is true if the partner came earlier\n        if found {\n            return partnerIndex, index\n        }\n        seen[number] = index \/\/ remember this number for later ones\n    }\n    return -1, -1 \/\/ no pair adds up to target\n}\n\nfunc main() {\n    fmt.Println(twoSum([]int{2, 7, 11, 15}, 9))\n    fmt.Println(twoSum([]int{3, 2, 4}, 6))\n    fmt.Println(twoSum([]int{1, 2}, 10))\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>0 1\n1 2\n-1 -1<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For each number, you work out the partner it needs to reach the target. If the map already holds that partner, you have the answer. If not, you save the current number and move on. One pass with a map makes this O(n) instead of checking every pair.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Program 5: Merge Overlapping Intervals<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport (\n    \"cmp\"\n    \"fmt\"\n    \"slices\"\n)\n\n\/\/ merge sorts by start time, then joins any interval that overlaps the last one.\nfunc merge(intervals [][2]int) [][2]int {\n    \/\/ Step 1: sort by start. cmp.Compare returns -1, 0 or 1 to say which is first.\n    slices.SortFunc(intervals, func(first, second [2]int) int {\n        return cmp.Compare(first[0], second[0])\n    })\n    \/\/ Step 2: walk through and join overlaps\n    var merged [][2]int\n    for _, current := range intervals {\n        last := len(merged) - 1\n        if last &gt;= 0 &amp;&amp; current[0] &lt;= merged[last][1] {\n            merged[last][1] = max(merged[last][1], current[1]) \/\/ overlap: stretch the end\n        } else {\n            merged = append(merged, current) \/\/ no overlap: start a new interval\n        }\n    }\n    return merged\n}\n\nfunc main() {\n    meetings := [][2]int{{8, 10}, {1, 3}, {2, 6}, {15, 18}, {9, 12}}\n    fmt.Println(merge(meetings))\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>[[1 6] [8 12] [15 18]]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">First the meetings are sorted by start time. Then each meeting either stretches the last merged one or starts a new one. After sorting, any overlap must be with the last merged interval. This is O(n log n) because of the sort.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Program 6: Product of Array Except Self<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\n\/\/ productExceptSelf multiplies everything to the left, then everything\n\/\/ to the right, without using division.\nfunc productExceptSelf(numbers []int) []int {\n    result := make([]int, len(numbers)) \/\/ make creates a slice of zeros\n    \/\/ Step 1: left to right, store the product of all items before i\n    leftProduct := 1\n    for i := 0; i &lt; len(numbers); i++ {\n        result[i] = leftProduct\n        leftProduct *= numbers[i]\n    }\n    \/\/ Step 2: right to left, multiply by the product of all items after i\n    rightProduct := 1\n    for i := len(numbers) - 1; i &gt;= 0; i-- {\n        result[i] *= rightProduct\n        rightProduct *= numbers[i]\n    }\n    return result\n}\n\nfunc main() {\n    fmt.Println(productExceptSelf([]int{1, 2, 3, 4}))\n    fmt.Println(productExceptSelf([]int{2, 0, 5}))\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>[24 12 8 6]\n[0 10 0]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The first loop stores the product of everything to the left of each spot. The second loop multiplies in everything to the right. Division would fail when the input has a zero, as in the second example. Two passes with running products avoid that problem.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Program 7: Check a Palindrome with Two Pointers<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\n\/\/ isPalindrome checks if a word reads the same from both ends.\nfunc isPalindrome(word string) bool {\n    left := 0              \/\/ starts at the first letter\n    right := len(word) - 1 \/\/ starts at the last letter\n    for left &lt; right {\n        if word[left] != word[right] {\n            return false \/\/ the two ends do not match\n        }\n        left++  \/\/ move in from the left\n        right-- \/\/ move in from the right\n    }\n    return true\n}\n\nfunc main() {\n    for _, word := range []string{\"level\", \"racecar\", \"golang\", \"noon\"} {\n        fmt.Println(word, isPalindrome(word))\n    }\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>level true\nracecar true\ngolang false\nnoon true<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This is the easiest two pointer program. One pointer starts at each end, and both move towards the middle. If any pair of letters differs, the word is not a palindrome. Programs 8 and 9 use the same idea with a smarter rule for which pointer moves.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Program 8: Container With Most Water (Two Pointers)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\n\/\/ maxArea starts with the widest container and moves the shorter wall inwards.\nfunc maxArea(heights []int) int {\n    left := 0\n    right := len(heights) - 1\n    best := 0\n    for left &lt; right {\n        width := right - left\n        area := width * min(heights[left], heights[right]) \/\/ water is limited by the shorter wall\n        best = max(best, area)\n        if heights[left] &lt; heights[right] {\n            left++ \/\/ moving the taller wall can never help\n        } else {\n            right--\n        }\n    }\n    return best\n}\n\nfunc main() {\n    fmt.Println(maxArea([]int{1, 8, 6, 2, 5, 4, 8, 3, 7}))\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>49<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">You start with the two outer walls, which give the widest container. Each step moves the shorter wall inwards, because only a taller wall could hold more water. The walls at index 1 (height 8) and index 8 (height 7) are 7 apart, so the area is 7 times 7. Two pointers turn an O(n squared) search into O(n).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Program 9: Three Sum to Zero<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport (\n    \"fmt\"\n    \"slices\"\n)\n\n\/\/ threeSum sorts, fixes one number, then uses two pointers for the other two.\nfunc threeSum(numbers []int) [][]int {\n    slices.Sort(numbers)\n    var result [][]int\n    for i := 0; i &lt; len(numbers)-2; i++ {\n        if i &gt; 0 &amp;&amp; numbers[i] == numbers[i-1] {\n            continue \/\/ skip duplicate first numbers\n        }\n        left := i + 1\n        right := len(numbers) - 1\n        for left &lt; right {\n            sum := numbers[i] + numbers[left] + numbers[right]\n            if sum &lt; 0 {\n                left++ \/\/ too small, so take a bigger number\n            } else if sum &gt; 0 {\n                right-- \/\/ too big, so take a smaller number\n            } else {\n                result = append(result, []int{numbers[i], numbers[left], numbers[right]})\n                for left &lt; right &amp;&amp; numbers[left] == numbers[left+1] {\n                    left++ \/\/ skip duplicate second numbers\n                }\n                left++\n                right--\n            }\n        }\n    }\n    return result\n}\n\nfunc main() {\n    fmt.Println(threeSum([]int{-1, 0, 1, 2, -1, -4}))\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>[[-1 -1 2] [-1 0 1]]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The outer loop fixes the first number. The two pointers then search the rest for a pair that brings the sum to zero. Sorting lets us skip duplicates easily and move the pointers with a clear rule. Many Go coding interview programs start with a sort for this reason. The total cost is O(n squared), which is the best known for this problem.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Dynamic Programming Go Coding Interview Programs<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Dynamic programming (DP) means solving a big problem by saving the answers to smaller ones. These Go coding interview programs show the three most asked DP shapes.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"640\" src=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-diagram-2-1024x640.png\" alt=\"Go coding interview programs coin change table filled from small amounts to the target\" class=\"wp-image-861\" srcset=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-diagram-2-1024x640.png 1024w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-diagram-2-300x188.png 300w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-diagram-2-768x480.png 768w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-diagram-2-1536x960.png 1536w, https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-diagram-2-2048x1280.png 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><figcaption class=\"wp-element-caption\">Each cell stores the fewest coins for that amount, built from cells already filled.<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Program 10: Climbing Stairs<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\n\/\/ ways counts how many ways you can climb steps stairs, taking 1 or 2 at a time.\n\/\/ ways(n) = ways(n-1) + ways(n-2), which is the Fibonacci pattern.\nfunc ways(steps int) int {\n    twoBack := 1 \/\/ ways to reach step 0\n    oneBack := 1 \/\/ ways to reach step 1\n    for i := 2; i &lt;= steps; i++ {\n        current := twoBack + oneBack\n        twoBack = oneBack \/\/ slide both answers forward by one step\n        oneBack = current\n    }\n    return oneBack\n}\n\nfunc main() {\n    for _, steps := range []int{1, 2, 3, 5, 10} {\n        fmt.Print(ways(steps), \" \")\n    }\n    fmt.Println()\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>1 2 3 8 89<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">To stand on step n, your last move came from step n-1 or n-2. So the answer for a step is the sum of the two answers before it. We only need the last two answers, so memory is O(1).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Program 11: Coin Change (Fewest Coins)<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\n\/\/ coinChange fills dp[a] = fewest coins that make amount a.\nfunc coinChange(coins []int, amount int) int {\n    dp := make([]int, amount+1) \/\/ dp[0] is 0: no coins make amount 0\n    for a := 1; a &lt;= amount; a++ {\n        dp[a] = amount + 1 \/\/ a value bigger than any real answer\n        for _, coin := range coins {\n            \/\/ use coin on top of the best answer for a-coin, if that is better\n            if coin &lt;= a &amp;&amp; dp[a-coin]+1 &lt; dp[a] {\n                dp[a] = dp[a-coin] + 1\n            }\n        }\n    }\n    if dp[amount] &gt; amount {\n        return -1 \/\/ the amount cannot be made\n    }\n    return dp[amount]\n}\n\nfunc main() {\n    fmt.Println(coinChange([]int{1, 2, 5}, 11))\n    fmt.Println(coinChange([]int{2}, 3))\n    fmt.Println(coinChange([]int{1, 5, 10, 20}, 36))\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>3\n-1\n4<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The table <code>dp<\/code> is filled from amount 1 up to the target. For each amount <code>a<\/code>, you try every coin and reuse the answer already saved for <code>a<\/code> minus that coin. For 11, the answer is 5 + 5 + 1. A greedy &#8220;biggest coin first&#8221; approach fails for some coin sets, which is why interviewers ask for DP here.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Program 12: Longest Common Subsequence<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\n\/\/ lcs builds a table where dp[i][j] is the answer for first[:i] and second[:j].\nfunc lcs(first, second string) int {\n    \/\/ Step 1: make a table with one extra row and column of zeros\n    dp := make([][]int, len(first)+1)\n    for i := range dp {\n        dp[i] = make([]int, len(second)+1)\n    }\n    \/\/ Step 2: fill it row by row\n    for i := 1; i &lt;= len(first); i++ {\n        for j := 1; j &lt;= len(second); j++ {\n            if first[i-1] == second[j-1] {\n                dp[i][j] = dp[i-1][j-1] + 1 \/\/ same letter: extend the diagonal\n            } else {\n                dp[i][j] = max(dp[i-1][j], dp[i][j-1]) \/\/ skip a letter from one side\n            }\n        }\n    }\n    return dp[len(first)][len(second)]\n}\n\nfunc main() {\n    fmt.Println(lcs(\"abcde\", \"ace\"), lcs(\"golang\", \"gopher\"), lcs(\"abc\", \"xyz\"))\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>3 2 0<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Each cell compares one letter from each word. When the letters match, you add 1 to the cell up and to the left. The common subsequence of &#8220;abcde&#8221; and &#8220;ace&#8221; is &#8220;ace&#8221;. The <code>diff<\/code> tool and Git use the same idea to compare file versions.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Backend Go Coding Interview Programs<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Program 13: Token Bucket Rate Limiter<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\n\/\/ Bucket allows bursts up to capacity, and refills rate tokens per second.\n\/\/ Time is passed in as seconds so the output is the same on every run.\ntype Bucket struct {\n    capacity float64 \/\/ the most tokens the bucket can hold\n    tokens   float64 \/\/ tokens left right now\n    rate     float64 \/\/ tokens added per second\n    lastTime float64 \/\/ when we last refilled\n}\n\n\/\/ Allow reports whether a request at time now may pass.\nfunc (bucket *Bucket) Allow(now float64) bool {\n    \/\/ Step 1: refill for the time that passed, but never above capacity\n    passed := now - bucket.lastTime\n    bucket.tokens = min(bucket.capacity, bucket.tokens+passed*bucket.rate)\n    bucket.lastTime = now\n    \/\/ Step 2: spend one token if there is one\n    if bucket.tokens &gt;= 1 {\n        bucket.tokens--\n        return true\n    }\n    return false\n}\n\nfunc main() {\n    bucket := &amp;Bucket{capacity: 3, tokens: 3, rate: 1} \/\/ 3 requests at once, then 1 per second\n    for _, now := range []float64{0, 0, 0, 0, 0.5, 1.2, 4} {\n        \/\/ %.1f prints one digit after the point, %v prints the value as it is\n        fmt.Printf(\"t=%.1f allowed=%v\\n\", now, bucket.Allow(now))\n    }\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>t=0.0 allowed=true\nt=0.0 allowed=true\nt=0.0 allowed=true\nt=0.0 allowed=false\nt=0.5 allowed=false\nt=1.2 allowed=true\nt=4.0 allowed=true<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">At the start, the bucket is full, so the first three requests pass at once. A fourth request then finds the bucket empty and is refused. By t=1.2, the bucket has refilled to 1.2 tokens, so one request passes. In real code, pass <code>time.Now()<\/code> instead, or use the <code>golang.org\/x\/time\/rate<\/code> package.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Program 14: Move Zeroes to the End In Place<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\n\/\/ moveZeroes copies every non-zero value forward, then fills the rest with 0.\nfunc moveZeroes(numbers []int) {\n    writeIndex := 0 \/\/ next position to write a non-zero value\n    for _, number := range numbers {\n        if number != 0 {\n            numbers[writeIndex] = number\n            writeIndex++\n        }\n    }\n    \/\/ every spot after the last non-zero value becomes 0\n    for i := writeIndex; i &lt; len(numbers); i++ {\n        numbers[i] = 0\n    }\n}\n\nfunc main() {\n    numbers := []int{0, 1, 0, 3, 12}\n    moveZeroes(numbers) \/\/ the slice is changed in place\n    fmt.Println(numbers)\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>[1 3 12 0 0]<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The loop reads every value, but it only writes the non-zero ones, at <code>writeIndex<\/code>. After that, the second loop fills the leftover spots with zeros. The order of the non-zero values stays the same, and no extra slice is used, which interviewers check for in Go coding interview programs. This read pointer and write pointer pattern also removes duplicates from sorted arrays.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Brute Force vs Optimal in Go Coding Interview Programs<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Interviewers want to see both the simple idea and the better one. The table below compares them for problems in this post.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Problem<\/th><th>Brute force<\/th><th>Optimal<\/th><\/tr><\/thead><tbody><tr><td>Longest unique substring<\/td><td>O(n cubed), check all<\/td><td>O(n), sliding window<\/td><\/tr><tr><td>Maximum subarray<\/td><td>O(n squared), all ranges<\/td><td>O(n), Kadane<\/td><\/tr><tr><td>Container with most water<\/td><td>O(n squared), all pairs<\/td><td>O(n), two pointers<\/td><\/tr><tr><td>Three sum<\/td><td>O(n cubed), all triples<\/td><td>O(n squared), sort plus two pointers<\/td><\/tr><tr><td>Coin change<\/td><td>Exponential, try all mixes<\/td><td>O(amount x coins), DP<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">A simple rule helps: say the brute force idea first in one sentence, then improve it. This shows clear thinking even before you write code.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common Mistakes in Go Coding Interview Programs<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Coding before clarifying:<\/strong> ask about empty input, negatives and duplicates first.<\/li>\n\n\n<li><strong>Forgetting edge cases:<\/strong> test an empty slice, one item and all equal items.<\/li>\n\n\n<li><strong>Relying on map order:<\/strong> sort keys when the output order matters.<\/li>\n\n\n<li><strong>Integer overflow:<\/strong> large sums may need <code>int64<\/code>, and Go <code>int<\/code> is 64-bit on most servers.<\/li>\n\n\n<li><strong>Silent coding:<\/strong> talk through your idea so the interviewer can follow and help.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Best Practices for Go Coding Interview Programs<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Learn the patterns,<\/strong> not individual answers: window, two pointers, BFS, DP and heaps.<\/li>\n\n\n<li><strong>Use the standard library:<\/strong> <code>slices.Sort<\/code>, <code>min<\/code>, <code>max<\/code> and <code>container\/list<\/code> save time.<\/li>\n\n\n<li><strong>Name variables clearly,<\/strong> like <code>left<\/code>, <code>right<\/code> and <code>best<\/code>.<\/li>\n\n\n<li><strong>State time and space Big O<\/strong> at the end without being asked.<\/li>\n\n\n<li><strong>Practise on a timer,<\/strong> about 25 minutes per problem.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Go Coding Interview Programs Interview Questions and Answers<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">These are the follow-up questions interviewers ask most, and they build on the Go coding interview programs above. Each code answer is complete, with real output from Go 1.27.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Concept Questions on Go Coding Interview Programs<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q1. What is Big O notation?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It describes how the work grows as the input grows. O(n) means double the input roughly doubles the work, while O(n squared) means double the input gives about four times the work.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q2. What is the difference between memoization and tabulation?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Memoization is top-down: a recursive function saves answers in a map. Tabulation is bottom-up: a loop fills a table from small cases, as in Programs 11 and 12.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q3. What does this program print?<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\n\/\/ fib returns the nth Fibonacci number and saves each answer in memo.\nfunc fib(number int, memo map[int]int) int {\n    if number &lt; 2 {\n        return number\n    }\n    saved, ok := memo[number] \/\/ ok is true if we solved this one before\n    if ok {\n        return saved \/\/ already solved, reuse it\n    }\n    memo[number] = fib(number-1, memo) + fib(number-2, memo)\n    return memo[number]\n}\n\nfunc main() {\n    memo := map[int]int{}\n    fmt.Println(fib(50, memo), len(memo))\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>12586269025 49<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Without the memo, <code>fib(50)<\/code> would take billions of calls. With it, each value from 2 to 50 is computed once, which is 49 entries.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Coding Questions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q4. How do you find the single number when every other number appears twice?<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\nfunc main() {\n    numbers := []int{4, 1, 2, 1, 2}\n    result := 0\n    for _, number := range numbers {\n        result ^= number \/\/ ^ is XOR; a ^ a is 0, so pairs cancel out\n    }\n    fmt.Println(result)\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>4<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Each pair of equal numbers cancels to 0, so only the single number is left. XOR uses O(1) memory, while a map would use O(n). Interviewers like this one as a quick follow-up.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q5. How do you find the majority element in O(1) memory?<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\n\/\/ majority uses Boyer-Moore voting: a different value cancels one vote for the candidate.\nfunc majority(numbers []int) int {\n    candidate := 0\n    count := 0\n    for _, number := range numbers {\n        if count == 0 {\n            candidate = number \/\/ no votes left, so pick a new candidate\n        }\n        if number == candidate {\n            count++\n        } else {\n            count--\n        }\n    }\n    return candidate\n}\n\nfunc main() {\n    fmt.Println(majority([]int{2, 2, 1, 1, 1, 2, 2}))\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>2<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Each number either adds a vote for the candidate or takes one away. The majority value appears more than half the time, so it survives all the cancelling.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q6. How do you check if you can reach the last index of a jump array?<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>package main\n\nimport \"fmt\"\n\n\/\/ canJump tracks the farthest index reachable so far.\nfunc canJump(numbers []int) bool {\n    farthest := 0\n    for index, step := range numbers {\n        if index &gt; farthest {\n            return false \/\/ this index can never be reached\n        }\n        farthest = max(farthest, index+step)\n    }\n    return true\n}\n\nfunc main() {\n    fmt.Println(canJump([]int{2, 3, 1, 1, 4}), canJump([]int{3, 2, 1, 0, 4}))\n}<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>true false<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This greedy check is O(n). In the second case, every path gets stuck at the 0 at index 3.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Interview Strategy Questions<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q7. What should you do if you cannot find the optimal solution?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Write the brute force solution cleanly and state its Big O. A correct slow answer with clear reasoning often scores better than a broken fast one.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q8. Should you use generics in an interview?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Only if the problem asks for a reusable type. For most problems, plain <code>[]int<\/code> keeps the code short and easy to follow.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q9. How do you test your code in a live interview?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Walk through one normal example line by line, then try an edge case, such as an empty slice or a single item. Say the variable values out loud as you go.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Q10. How many problems should you practise?<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Quality beats quantity. Solve about 75 to 100 problems that cover the main patterns, then repeat the ones you got wrong a week later.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Practice Task<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">To practise Go coding interview programs, solve &#8220;minimum window substring&#8221;: find the smallest part of <code>\"ADOBECODEBANC\"<\/code> that contains all letters of <code>\"ABC\"<\/code>, which is <code>\"BANC\"<\/code>. Hint: use the sliding window from Program 2 with a map of needed letter counts.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Official Resources<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><a href=\"https:\/\/pkg.go.dev\/container\/list\">container\/list package documentation<\/a><\/li>\n\n\n<li><a href=\"https:\/\/pkg.go.dev\/slices\">slices package documentation<\/a><\/li>\n\n\n<li><a href=\"https:\/\/go.dev\/doc\/effective_go\">Effective Go<\/a><\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Quick Recap<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go coding interview programs test correct code, clear talk and good Big O.<\/li>\n\n\n<li>Sliding window and two pointers turn many O(n squared) searches into O(n).<\/li>\n\n\n<li>An LRU cache combines a map with a doubly linked list for O(1) operations.<\/li>\n\n\n<li>Dynamic programming saves answers to small cases to solve big ones.<\/li>\n\n\n<li>Always state the brute force idea first, then improve it.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">What&#8217;s Next?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">You have finished all six levels of the Go Programs series. Coming soon: Build a Go Backend Service End to End, a hands-on project post. For more practice now, go through the <a href=\"https:\/\/smitabharat.com\/blog\/go-coding-scenario-questions\/\">Go coding scenario questions<\/a> or browse every topic in the <a href=\"https:\/\/smitabharat.com\/blog\/go-interview-questions-hub\/\">Go interview questions hub<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Go coding interview programs are the problems companies give you in a live coding round, where you must write correct code, explain it and&hellip;<\/p>\n","protected":false},"author":1,"featured_media":859,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_swapz_level":"","_swapz_series_part":0,"_swapz_hide_toc":false,"_swapz_hide_featured":false,"_swapz_description":"","footnotes":""},"categories":[106],"tags":[96,124,95,11,104],"swapz_series":[],"class_list":["post-862","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-go-programs","tag-beginner","tag-go-coding-interview","tag-go-interview-questions","tag-go-lang","tag-go-programs"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.9 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Go Coding Interview Programs: LRU, Window, DP<\/title>\n<meta name=\"description\" content=\"Go coding interview programs with output: LRU cache, sliding window, Kadane, intervals, two pointers, coin change and a rate limiter, plus strategy Q&amp;A.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Go Coding Interview Programs: LRU, Window, DP\" \/>\n<meta property=\"og:description\" content=\"Go coding interview programs with output: LRU cache, sliding window, Kadane, intervals, two pointers, coin change and a rate limiter, plus strategy Q&amp;A.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/\" \/>\n<meta property=\"og:site_name\" content=\"Smita Bharat - Blog\" \/>\n<meta property=\"article:published_time\" content=\"2026-10-11T03:30:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-28T19:59:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-featured.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1260\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Smita\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Smita\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"20 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-coding-interview-programs\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-coding-interview-programs\\\/\"},\"author\":{\"name\":\"Smita\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"headline\":\"Go Coding Interview Programs: LRU, Sliding Window and DP\",\"datePublished\":\"2026-10-11T03:30:00+00:00\",\"dateModified\":\"2026-11-28T19:59:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-coding-interview-programs\\\/\"},\"wordCount\":2082,\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-coding-interview-programs\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-coding-interview-programs-featured.png\",\"keywords\":[\"Beginner\",\"Go Coding Interview\",\"Go Interview Questions\",\"Go Lang\",\"Go Programs\"],\"articleSection\":[\"Go Programs\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-coding-interview-programs\\\/\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-coding-interview-programs\\\/\",\"name\":\"Go Coding Interview Programs: LRU, Window, DP\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-coding-interview-programs\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-coding-interview-programs\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-coding-interview-programs-featured.png\",\"datePublished\":\"2026-10-11T03:30:00+00:00\",\"dateModified\":\"2026-11-28T19:59:23+00:00\",\"description\":\"Go coding interview programs with output: LRU cache, sliding window, Kadane, intervals, two pointers, coin change and a rate limiter, plus strategy Q&A.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-coding-interview-programs\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-coding-interview-programs\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-coding-interview-programs\\\/#primaryimage\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-coding-interview-programs-featured.png\",\"contentUrl\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/10\\\/go-coding-interview-programs-featured.png\",\"width\":2400,\"height\":1260,\"caption\":\"Go Coding Interview Programs featured image: LRU cache and DP output\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/go-coding-interview-programs\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Go Coding Interview Programs: LRU, Sliding Window and DP\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/\",\"name\":\"Smita Bharat Blog\",\"description\":\"Golang &amp; Backend Development Tutorials and Interview Questions\",\"publisher\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\"},\"alternateName\":\"Smita Bharat\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/27a1b1067d396703215c54acedbfd339\",\"name\":\"Smita\",\"logo\":{\"@id\":\"https:\\\/\\\/smitabharat.com\\\/blog\\\/#\\\/schema\\\/person\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/smitabharat.com\\\/blog\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Go Coding Interview Programs: LRU, Window, DP","description":"Go coding interview programs with output: LRU cache, sliding window, Kadane, intervals, two pointers, coin change and a rate limiter, plus strategy Q&A.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/","og_locale":"en_US","og_type":"article","og_title":"Go Coding Interview Programs: LRU, Window, DP","og_description":"Go coding interview programs with output: LRU cache, sliding window, Kadane, intervals, two pointers, coin change and a rate limiter, plus strategy Q&A.","og_url":"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/","og_site_name":"Smita Bharat - Blog","article_published_time":"2026-10-11T03:30:00+00:00","article_modified_time":"2026-11-28T19:59:23+00:00","og_image":[{"width":2400,"height":1260,"url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-featured.png","type":"image\/png"}],"author":"Smita","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Smita","Est. reading time":"20 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/#article","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/"},"author":{"name":"Smita","@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"headline":"Go Coding Interview Programs: LRU, Sliding Window and DP","datePublished":"2026-10-11T03:30:00+00:00","dateModified":"2026-11-28T19:59:23+00:00","mainEntityOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/"},"wordCount":2082,"publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-featured.png","keywords":["Beginner","Go Coding Interview","Go Interview Questions","Go Lang","Go Programs"],"articleSection":["Go Programs"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/","url":"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/","name":"Go Coding Interview Programs: LRU, Window, DP","isPartOf":{"@id":"https:\/\/smitabharat.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/#primaryimage"},"image":{"@id":"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/#primaryimage"},"thumbnailUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-featured.png","datePublished":"2026-10-11T03:30:00+00:00","dateModified":"2026-11-28T19:59:23+00:00","description":"Go coding interview programs with output: LRU cache, sliding window, Kadane, intervals, two pointers, coin change and a rate limiter, plus strategy Q&A.","breadcrumb":{"@id":"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/#primaryimage","url":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-featured.png","contentUrl":"https:\/\/smitabharat.com\/blog\/wp-content\/uploads\/2026\/10\/go-coding-interview-programs-featured.png","width":2400,"height":1260,"caption":"Go Coding Interview Programs featured image: LRU cache and DP output"},{"@type":"BreadcrumbList","@id":"https:\/\/smitabharat.com\/blog\/go-coding-interview-programs\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/smitabharat.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Go Coding Interview Programs: LRU, Sliding Window and DP"}]},{"@type":"WebSite","@id":"https:\/\/smitabharat.com\/blog\/#website","url":"https:\/\/smitabharat.com\/blog\/","name":"Smita Bharat Blog","description":"Golang &amp; Backend Development Tutorials and Interview Questions","publisher":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339"},"alternateName":"Smita Bharat","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/smitabharat.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/27a1b1067d396703215c54acedbfd339","name":"Smita","logo":{"@id":"https:\/\/smitabharat.com\/blog\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/smitabharat.com\/blog"]}]}},"_links":{"self":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/862","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/comments?post=862"}],"version-history":[{"count":1,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/862\/revisions"}],"predecessor-version":[{"id":904,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/posts\/862\/revisions\/904"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media\/859"}],"wp:attachment":[{"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/media?parent=862"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/categories?post=862"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/tags?post=862"},{"taxonomy":"swapz_series","embeddable":true,"href":"https:\/\/smitabharat.com\/blog\/wp-json\/wp\/v2\/swapz_series?post=862"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}