Senior-Level DSA Topics for Google
š Concept
Google's coding interviews test DSA at a higher bar for senior candidates. You're expected to identify the optimal approach quickly and implement it cleanly in Kotlin.
Essential topic areas ranked by Google frequency:
- Arrays & Strings ā Two pointers, sliding window, prefix sums, binary search
- Trees & Graphs ā BFS/DFS, shortest path, topological sort, tree traversals
- Dynamic Programming ā State definition, transitions, optimization
- Hash Maps & Sets ā Frequency counting, grouping, caching
- Stacks & Queues ā Monotonic stack, BFS, parentheses matching
- Heaps (Priority Queues) ā Top-K, median, merge K sorted lists
- Linked Lists ā Reversal, cycle detection, merge
- Greedy ā Interval scheduling, minimum operations
- Tries ā Autocomplete, word search, longest prefix
- Union-Find ā Connected components, cycle detection
Senior-level expectations:
- Identify the pattern within 2-3 minutes
- Discuss time/space complexity BEFORE coding
- Write clean, idiomatic Kotlin (not Java translated to Kotlin)
- Handle edge cases without prompting
- Optimize from brute force to optimal proactively
Problem-solving framework:
1. Understand ā Restate the problem, ask clarifying questions
2. Plan ā Identify pattern, discuss approach, state complexity
3. Code ā Write clean solution with good variable names
4. Test ā Walk through 2 examples + 1 edge case
5. Optimize ā If not optimal, discuss how to improve
š» Code Example
1// Google-frequency coding patterns in Kotlin23// 1. Sliding Window ā Max sum of subarray of size K4fun maxSumSubarray(arr: IntArray, k: Int): Int {5 var windowSum = arr.slice(0 until k).sum()6 var maxSum = windowSum7 for (i in k until arr.size) {8 windowSum += arr[i] - arr[i - k]9 maxSum = maxOf(maxSum, windowSum)10 }11 return maxSum12}1314// 2. Two Pointers ā Container with most water15fun maxArea(height: IntArray): Int {16 var left = 017 var right = height.lastIndex18 var maxWater = 019 while (left < right) {20 val water = minOf(height[left], height[right]) * (right - left)21 maxWater = maxOf(maxWater, water)22 if (height[left] < height[right]) left++ else right--23 }24 return maxWater25}2627// 3. BFS ā Shortest path in unweighted graph28fun shortestPath(graph: Map<Int, List<Int>>, start: Int, end: Int): Int {29 val queue: Queue<Pair<Int, Int>> = LinkedList()30 val visited = mutableSetOf(start)31 queue.add(start to 0)32 while (queue.isNotEmpty()) {33 val (node, dist) = queue.poll()34 if (node == end) return dist35 for (neighbor in graph[node] ?: emptyList()) {36 if (neighbor !in visited) {37 visited.add(neighbor)38 queue.add(neighbor to dist + 1)39 }40 }41 }42 return -143}4445// 4. Dynamic Programming ā Longest Increasing Subsequence46fun lengthOfLIS(nums: IntArray): Int {47 // Patience sorting ā O(n log n)48 val tails = mutableListOf<Int>()49 for (num in nums) {50 val pos = tails.binarySearch(num).let { if (it < 0) -(it + 1) else it }51 if (pos == tails.size) tails.add(num) else tails[pos] = num52 }53 return tails.size54}5556// 5. Monotonic Stack ā Next greater element57fun nextGreaterElements(nums: IntArray): IntArray {58 val result = IntArray(nums.size) { -1 }59 val stack = ArrayDeque<Int>() // indices60 for (i in nums.indices) {61 while (stack.isNotEmpty() && nums[stack.last()] < nums[i]) {62 result[stack.removeLast()] = nums[i]63 }64 stack.addLast(i)65 }66 return result67}
šļø Practice Exercise
50 Must-Practice Problems for Google:
Arrays & Strings (10):
- Two Sum (Easy) ā HashMap
- Best Time to Buy/Sell Stock (Easy) ā Kadane's
- Container With Most Water (Medium) ā Two pointers
- 3Sum (Medium) ā Sort + two pointers
- Minimum Window Substring (Hard) ā Sliding window
- Longest Substring Without Repeating (Medium) ā Sliding window
- Product of Array Except Self (Medium) ā Prefix/suffix
- Merge Intervals (Medium) ā Sort + greedy
- Trapping Rain Water (Hard) ā Two pointers
- Longest Consecutive Sequence (Medium) ā HashSet
Trees & Graphs (10): 11. Binary Tree Level Order Traversal (Medium) ā BFS 12. Validate BST (Medium) ā Inorder 13. Lowest Common Ancestor (Medium) ā Recursion 14. Serialize/Deserialize Binary Tree (Hard) ā BFS/preorder 15. Number of Islands (Medium) ā BFS/DFS 16. Course Schedule (Medium) ā Topological sort 17. Word Ladder (Hard) ā BFS 18. Clone Graph (Medium) ā BFS + HashMap 19. Alien Dictionary (Hard) ā Topological sort 20. Binary Tree Max Path Sum (Hard) ā DFS
Dynamic Programming (10): 21. Climbing Stairs (Easy) ā Fibonacci pattern 22. Coin Change (Medium) ā Bottom-up DP 23. Longest Increasing Subsequence (Medium) ā Patience sorting 24. Word Break (Medium) ā DP + Trie 25. Edit Distance (Medium) ā 2D DP 26. Unique Paths (Medium) ā 2D DP 27. House Robber (Medium) ā Linear DP 28. Decode Ways (Medium) ā Linear DP 29. Partition Equal Subset Sum (Medium) ā 0/1 Knapsack 30. Regular Expression Matching (Hard) ā 2D DP
Remaining (20): LRU Cache, Merge K Sorted Lists, Design Hit Counter, Implement Trie, Find Median from Data Stream, Task Scheduler, Min Stack, Valid Parentheses, Daily Temperatures, Top K Frequent Elements, Kth Largest Element, Meeting Rooms II, Number of Connected Components, Redundant Connection, Design Twitter, Max Frequency Stack, Sliding Window Maximum, Palindrome Partitioning, Word Search II, Accounts Merge
ā ļø Common Mistakes
Jumping into coding without discussing the approach ā Google evaluates your thought process, not just the answer
Not considering all edge cases ā empty input, single element, all duplicates, overflow
Writing verbose Java-style Kotlin ā use Kotlin idioms (let, apply, destructuring, extension functions)
Not optimizing proactively ā if you write O(n²), immediately discuss how to reach O(n) or O(n log n)
Forgetting to test your code ā walk through at least 2 examples after writing
š¼ Interview Questions
š¤ Mock Interview
Mock interview is powered by AI for Senior-Level DSA Topics for Google. Login to unlock this feature.