Dev Skills
Go·Section 3 of 15 · 16 lessons · about 15 hours

DSA in Go (Golang): coding interview problems, solved

How to read judge input fast, then fifteen problems campus hiring tests and online assessments ask most (maps, slices, linked lists, trees, recursion, DP, graphs, sliding windows), each solved idiomatically in Go with the trap that costs marks.

  1. 01Fast input and output for online judges
    How to read the input HackerRank, CodeChef and company OAs send on stdin, and print the answer fast enough to pass the time limit.
    Graded challenge
  2. 02Two sum with a map
    The most-asked warm-up in any coding round, and the cleanest demonstration of why a map beats a nested loop.
    Graded challenge
  3. 03Reverse and rotate a slice in place
    Two pointers, the three-reversal trick, and the slice aliasing that makes "in place" mean what it says.
    Graded challenge
  4. 04Frequency count and top K
    Count with a map, rank with a sort or a heap, and never let map order leak into your answer.
    Graded challenge
  5. 05Valid parentheses with a slice as a stack
    Go has no stack type, because a slice already is one. Push with append, pop by re-slicing.
    Graded challenge
  6. 06Binary search, by hand and from the stdlib
    Write it once without an off-by-one, then know when `slices.BinarySearch` and `sort.Search` do it for you.
    Graded challenge
  7. 07LRU cache with container/list and a map
    The design question disguised as a coding question: two structures, each covering what the other cannot.
    Graded challenge
  8. 08Reverse a linked list
    Three pointers and one saved link. The question that checks you can move pointers without losing the rest of the list.
    Graded challenge
  9. 09Detect a cycle with two pointers
    Floyd's tortoise and hare: find a loop in a linked list with no extra memory.
    Graded challenge
  10. 10Merge two sorted lists
    A dummy head node removes every special case, and the leftover tail is attached in one line.
    Graded challenge
  11. 11Binary tree depth and level order
    Recursion for depth, a slice as a queue for level order. The two shapes every tree question uses.
    Graded challenge
  12. 12Subsets and permutations with backtracking
    Choose, recurse, undo. And the one-line copy that stops every answer turning into the same slice.
    Graded challenge
  13. 13Dynamic programming: stairs, coins, LCS
    Write the answer for a small case in terms of smaller ones, then fill a table from the bottom up.
    Graded challenge
  14. 14Number of islands: DFS on a grid
    A grid is a graph in disguise. Find unvisited land, flood it, count one.
    Graded challenge
  15. 15Merge overlapping intervals
    Sort by start, then one pass. The sort does the hard part.
    Graded challenge
  16. 16Longest substring without repeating characters
    A window with two edges and a map of where each character was last seen. Rune-aware, so it counts characters, not bytes.
    Graded challenge