Goldman Sachs Coding Interview Questions 2026 — HackerRank OA, CoderPad & Superday

Goldman Sachs is one of the most coveted destinations for engineers who want to work at the intersection of finance and technology. GS Engineering builds the systems that power global markets — trading platforms, risk engines, real-time data pipelines, and distributed financial infrastructure operating at massive scale.

Unlike pure product companies, Goldman Sachs places heavy emphasis on Java, distributed systems fundamentals, and puzzle-style reasoning alongside standard DSA. Their interview process is rigorous and unique: a HackerRank assessment, a HireVue behavioral screen, CoderPad technical rounds, and a Superday with back-to-back interviews.

This guide covers Goldman Sachs' full hiring process and 50 actual coding problems reported by candidates from the Engineering Analyst, SDE-1, and SDE-2 interview tracks across 2024–2026.

Goldman Sachs Hiring Process (2026)

1. Online Application

  • Apply via goldmansachs.com/careers. GS recruits heavily through campus drives and the Engineering Campus Hiring Program (ECHP).
  • Tip: Tailor your resume to highlight systems work, trading or fintech projects, Java/Python experience, and any quantitative coursework. GS values engineering depth over breadth.

2. HackerRank Online Assessment — 90–120 minutes

  • Typically 2 medium-hard DSA coding problems plus multiple choice questions (MCQs) on data structures, algorithms, OOP, and sometimes SQL.
  • Some tracks have 7 sections with 70 total questions in 120 minutes (campus program format).
  • Tip: The MCQ section tests conceptual clarity — know time complexities, OOP principles, and basic SQL cold. For coding, GS expects clean, correct code with edge case handling.

3. HireVue Video Interview

  • A pre-recorded behavioral interview. You answer questions on camera with no live interviewer.
  • Questions focus on motivation for GS, teamwork, handling conflict, and learning from failure.
  • Tip: Keep answers concise and structured. GS reviewers watch many videos — lead with impact, not context.

4. CoderPad Technical Rounds — 2 Rounds (45–60 min each)

  • Live coding with an interviewer on CoderPad. Each round has 1–2 medium/hard problems.
  • GS interviewers are known for follow-up questions and asking you to optimize further.
  • Tip: Think out loud, state complexity after every solution, and be ready to code in Java or Python from scratch. GS often asks Java-specific follow-ups (generics, collections, concurrency).

5. Superday — 3–5 Back-to-Back Rounds

  • Mix of technical (DSA + system design) and behavioural interviews conducted in one day.
  • System design becomes relevant for SDE-2 and above.
  • Tip: Pace yourself. Superday is a marathon. Stay consistent in the later rounds — interviewers compare notes.

6. Offer

  • GS offers come with base salary, annual bonus (significant in finance), and RSUs.
  • Response time is typically 1–2 weeks after Superday.

Preparation Resources

Part 1 — HackerRank OA Questions

Goldman Sachs OA consists of 2 medium-hard DSA problems and MCQs. Both problems are visible from the start. Read both before starting and pick the easier one first.

1. First Unique Character in a String Easy

OAStrings · HashingLeetCode:#387

Given a string s, find the index of its first non-repeating character. Return -1 if none exists.

Input:  s = "leetcode"
Output: 0   ('l' appears only once, at index 0)

Input:  s = "aabb"
Output: -1

Approach: Build a frequency map in one pass. In the second pass, return the index of the first character with frequency 1.

Complexity: Time O(n) · Space O(1) (at most 26 chars)

2. Reduce String by Removing K Consecutive Identical Characters Medium

OA · Frequently ReportedStrings · StackLeetCode:#1209

Given a string s and integer k, repeatedly remove groups of k consecutive identical characters until no more removals are possible. Return the resulting string.

Input:  s = "deeedbbcccbdaa",  k = 3
Output: "aa"
Steps:  "deeedbbcccbdaa" → remove "eee" → "dbbcccbdaa"
        → remove "ccc" → "dbbdbaa" → remove "bbb"? no
        → remove "bb"? no (k=3) → hmm
        Actually: "deeedbbcccbdaa" → "dbbcccbdaa" → "dbbdaa" → "aa"

Approach: Stack of (character, count) pairs. Push each character. If the top of the stack has the same character, increment its count. When count reaches k, pop it. Reconstruct from the stack.

Complexity: Time O(n) · Space O(n)

3. Shortest Subarray with Sum at Least K Hard

OA · ReportedArrays · Prefix Sum · DequeLeetCode:#862

Given an integer array nums and integer k, return the length of the shortest non-empty subarray with sum at least k. If no such subarray, return -1. Array may contain negatives.

Input:  nums = [2,-1,2],  k = 3
Output: 3   (entire array sums to 3)

Input:  nums = [1,2],  k = 4
Output: -1

Approach: Compute prefix sums. Use a monotonic deque to maintain increasing prefix sum indices. For each j, pop from the front while P[j] - P[front] >= k and update minimum length. Pop from the back while P[j] <= P[back].

Complexity: Time O(n) · Space O(n)

4. Four Indices Where a+b = c+d Medium

OA · GFG ReportedArrays · Hashing

Given an array of n integers, find four distinct indices (i, j, k, l) such that arr[i] + arr[j] = arr[k] + arr[l]. Print any valid set of indices.

Input:  arr = [3,4,7,1,2,9,8]
Output: (0,5,2,3)   → 3+9 = 7+... wait
        arr[0]+arr[5] = 3+9 = 12, arr[2]+arr[4] = 7+5? 
        Valid: (1,3,0,4) → 4+1 = 3+2 = 5 ✓

Approach: Use a hash map where the key is a pair sum and the value is the first pair of indices that produced it. For each pair (i, j), if arr[i]+arr[j] is already in the map, output both pairs. Otherwise store it.

Complexity: Time O(n²) · Space O(n²)

5. Ways to Reach Target as Sum of 3 Elements (DP) Hard

OA · Frequently ReportedArrays · DP

Given an array of integers, for each index i, calculate the number of ways the value arr[i] can be expressed as a sum of exactly 3 integers chosen from arr[0..i-1] (with infinite supply, repetition allowed).

Input:  arr = [1,2,3,4]
For i=2 (val=3): ways to form 3 from {1,2} with 3 picks:
  1+1+1=3 → 1 way
Output for index 2: 1

For i=3 (val=4): ways from {1,2,3}:
  1+1+2=4, 1+3+? no... 
  Combinations: (1,1,2) → 1 way
Output for index 3: 1

Approach: For each index i, solve a "coin change — count ways" variant: use coins arr[0..i-1] to form arr[i] using exactly 3 coins. Use 2D DP: dp[coins][amount] = ways to form amount using exactly coins coins. Reset for each index.

Complexity: Time O(n² × max_val) · Space O(n × max_val)

6. Taxi Passenger Path on Grid Medium

OA · GS ReportedDP · Grid

A taxi starts at (0,0) and must reach (n-1,n-1) on an n×n grid. The taxi can carry multiple passengers. Passenger locations are marked on the grid. The taxi can only move right or down. Find the path that picks up the maximum number of passengers.

Input:  grid = [[0,1,0],[0,0,1],[1,0,0]]
Output: 2   (path 0,0 → 0,1 → 1,1 → 1,2 → 2,2 picks up (0,1) and (1,2))

Approach: DP where dp[i][j] = max passengers collected reaching (i,j). dp[i][j] = grid[i][j] + max(dp[i-1][j], dp[i][j-1]).

Complexity: Time O(n²) · Space O(n²)

7. Array Manipulation with Sliding Window Medium

OAArrays · Sliding WindowLeetCode:&#35;2461

Given an array nums and integer k, find the maximum sum of a subarray of length k where all elements are distinct.

Input:  nums = [1,5,4,2,9,9,9],  k = 3
Output: 15   (subarray [4,2,9] — all distinct, sum=15)

Approach: Sliding window of size k with a frequency map. Maintain a count of distinct elements. When window has exactly k distinct elements, check sum. Slide right, remove leftmost.

Complexity: Time O(n) · Space O(k)

8. Palindrome Check with at Most One Removal Easy

OA · ReportedStrings · Two PointersLeetCode:&#35;680

Given a string s, return true if it can become a palindrome by removing at most one character.

Input:  s = "abca"
Output: true   (remove 'b' → "aca" or remove 'c' → "aba")

Input:  s = "abc"
Output: false

Approach: Two pointers from both ends. When a mismatch is found, try skipping either the left or right character and check if the remainder is a palindrome.

Complexity: Time O(n) · Space O(1)

Part 2 — CoderPad Technical Round Questions

Live coding with a GS interviewer on CoderPad. Medium-hard problems, 45–60 minutes, with follow-ups. GS interviewers push hard on complexity and optimisation.

9. Trapping Rain Water Hard

CoderPad · ReportedArrays · Two PointersLeetCode:&#35;42

Given an elevation map, compute how much water it can trap after raining.

Input:  height = [0,1,0,2,1,0,1,3,2,1,2,1]
Output: 6

Approach: Two pointers. Maintain leftMax and rightMax. Water at each position = min(leftMax, rightMax) - height[i]. Move the pointer with the smaller max inward.

Complexity: Time O(n) · Space O(1)

Follow-up: What if the elevation map is 2D (water trapped in a 3D container)? Use a min-heap BFS from the borders inward.

10. Number of Islands Medium

CoderPad · ReportedGraphs · DFS · BFSLeetCode:&#35;200

Count the number of islands (connected groups of '1's) in a 2D binary grid.

Input:  grid = [["1","1","0","0"],
                ["1","1","0","1"],
                ["0","0","0","1"]]
Output: 2

Approach: DFS from every unvisited '1'. Mark all connected cells as visited. Increment island count per DFS call.

Complexity: Time O(m×n) · Space O(m×n)

Follow-up: What if the grid updates dynamically (add land cells one at a time)? Use Union-Find with path compression.

11. Merge Two Sorted Arrays Easy

CoderPad · ReportedArrays · Two PointersLeetCode:&#35;88

Merge two sorted arrays nums1 (with extra space at the end) and nums2 in-place into nums1.

Input:  nums1=[1,2,3,0,0,0], m=3, nums2=[2,5,6], n=3
Output: [1,2,2,3,5,6]

Approach: Three pointers starting from the end. Compare elements from the back of both arrays and place the larger one at the tail of nums1.

Complexity: Time O(m+n) · Space O(1)

Follow-up (GS specific): Count the number of occurrences of each number in the merged array and print a frequency map.

12. Minimum Window Substring Hard

CoderPadStrings · Sliding WindowLeetCode:&#35;76

Return the smallest window in s that contains all characters of t.

Input:  s = "ADOBECODEBANC",  t = "ABC"
Output: "BANC"

Approach: Sliding window. Expand right until all chars of t covered, shrink left to minimize. Track the shortest valid window.

Complexity: Time O(n) · Space O(t)

13. String Transformation — Minimum Steps Medium

CoderPad · ReportedStrings · BFS · DPLeetCode:&#35;127

Find the fewest single-character substitutions to transform beginWord into endWord using only words from a dictionary.

Input:  begin="hit", end="cog", dict=["hot","dot","dog","lot","log","cog"]
Output: 5   (hit→hot→dot→dog→cog)

Approach: BFS treating each word as a graph node. For each word, try all single-char mutations and check the dictionary.

Complexity: Time O(M²×N) · Space O(M×N)

14. Kth Largest Element in a Stream Medium

CoderPad · GS Finance RelevantHeaps · DesignLeetCode:&#35;703

Design a class that finds the Kth largest element in a stream of integers. Implement add(val) which adds a new value and returns the current Kth largest.

KthLargest(3, [4,5,8,2]) → add(3)=4, add(5)=5, add(10)=8, add(9)=8, add(4)=8

Approach: Min-heap of size k. On each add, push the new value. If heap size exceeds k, pop the minimum. The top of the heap is always the Kth largest.

Complexity: Time O(log k) per add · Space O(k)

Why GS asks this: Directly mirrors real-time financial data streams where you track top-K prices.

15. LRU Cache Medium

CoderPad · Classic DesignDesign · Hash Map · Linked ListLeetCode:&#35;146

Implement get(key) and put(key, value) both in O(1) with LRU eviction.

LRUCache(2) → put(1,1) → put(2,2) → get(1)=1
→ put(3,3) [evicts 2] → get(2)=-1

Approach: Doubly linked list + hash map. Move accessed nodes to head; evict from tail.

Complexity: Time O(1) per operation · Space O(capacity)

Part 3 — Superday / Onsite Questions

Superday has 3–5 consecutive rounds mixing DSA and system design. GS interviewers are known for puzzle-style questions and follow-ups on OOP and Java specifics.

Arrays & Mathematics

16. Maximum Product Subarray Medium

SuperdayArrays · DPLeetCode:&#35;152

Find the contiguous subarray with the largest product.

Input:  nums = [2,3,-2,4]
Output: 6   (subarray [2,3])

Input:  nums = [-2,0,-1]
Output: 0

Approach: Track both maxProd and minProd at each step (negatives can flip). Update global max at each index.

Complexity: Time O(n) · Space O(1)

17. Jump Game II — Minimum Jumps Medium

SuperdayArrays · GreedyLeetCode:&#35;45

Return the minimum number of jumps to reach the last index.

Input:  nums = [2,3,1,1,4]
Output: 2

Approach: Greedy. Track curEnd and farthest. Increment jumps when index hits curEnd.

Complexity: Time O(n) · Space O(1)

18. Stock Buy Sell for Maximum Profit (Multiple Transactions) Medium

Superday · Finance RelevantArrays · GreedyLeetCode:&#35;122

Given daily stock prices, find the maximum profit with unlimited buy/sell transactions (must sell before buying again).

Input:  prices = [7,1,5,3,6,4]
Output: 7   (buy@1 sell@5 = 4, buy@3 sell@6 = 3, total 7)

Approach: Greedy — add every upward price difference to profit. Equivalent to buying at every valley and selling at every peak.

Complexity: Time O(n) · Space O(1)

19. Rotate Image (Matrix 90°) Medium

SuperdayArrays · MatrixLeetCode:&#35;48

Rotate an n×n matrix 90° clockwise in-place.

Input:  [[1,2,3],[4,5,6],[7,8,9]]
Output: [[7,4,1],[8,5,2],[9,6,3]]

Approach: Transpose the matrix (swap [i][j] with [j][i]), then reverse each row.

Complexity: Time O(n²) · Space O(1)

20. Find All Duplicates in Array Medium

SuperdayArrays · HashingLeetCode:&#35;442

Given an array of integers where 1 ≤ arr[i] ≤ n, find all elements that appear twice. Must run in O(n) time and O(1) extra space.

Input:  nums = [4,3,2,7,8,2,3,1]
Output: [2,3]

Approach: For each element x, negate nums[|x|-1]. If it's already negative, |x| is a duplicate.

Complexity: Time O(n) · Space O(1)

Strings

21. Longest Palindromic Substring Medium

SuperdayStrings · DPLeetCode:&#35;5

Find the longest substring of s that is a palindrome.

Input:  s = "babad"
Output: "bab"  (or "aba")

Approach: Expand around every character and gap as palindrome centers. Track the longest found.

Complexity: Time O(n²) · Space O(1)

22. Group Anagrams Medium

SuperdayStrings · HashingLeetCode:&#35;49

Group strings that are anagrams of each other.

Input:  ["eat","tea","tan","ate","nat","bat"]
Output: [["eat","tea","ate"],["tan","nat"],["bat"]]

Approach: Sort each string as the hash map key. Group all strings with the same sorted key.

Complexity: Time O(n × k log k) · Space O(n×k)

23. Longest Common Subsequence Medium

SuperdayStrings · DPLeetCode:&#35;1143

Find the length of the longest common subsequence of two strings.

Input:  text1 = "abcde",  text2 = "ace"
Output: 3   (LCS = "ace")

Approach: 2D DP. If chars match: dp[i][j] = dp[i-1][j-1] + 1. Else: max(dp[i-1][j], dp[i][j-1]).

Complexity: Time O(m×n) · Space O(m×n)

Linked Lists

24. Reverse Linked List in Groups of K Hard

SuperdayLinked ListsLeetCode:&#35;25

Reverse every k nodes of a linked list. Leave remaining nodes as-is if fewer than k.

Input:  head=1→2→3→4→5,  k=2
Output: 2→1→4→3→5

Approach: Recursively reverse groups of k. First check if at least k nodes remain.

Complexity: Time O(n) · Space O(n/k) recursion

25. Detect Cycle in Linked List Easy

SuperdayLinked Lists · Two PointersLeetCode:&#35;141

Detect if a linked list has a cycle.

Approach: Floyd's cycle detection — slow pointer moves 1 step, fast moves 2. If they meet, a cycle exists.

Complexity: Time O(n) · Space O(1)

Follow-up: Find the start of the cycle (LeetCode #142).

Trees

26. Binary Tree Level Order Traversal Medium

SuperdayTrees · BFSLeetCode:&#35;102

Return all node values level by level.

Input:  root=[3,9,20,null,null,15,7]
Output: [[3],[9,20],[15,7]]

Approach: BFS with a queue. For each level, process all nodes in the current queue snapshot.

Complexity: Time O(n) · Space O(w) where w = max width

27. Lowest Common Ancestor of BST Medium

SuperdayTrees · BSTLeetCode:&#35;235

Find the LCA of two nodes in a BST.

Input:  root=[6,2,8,0,4,7,9], p=2, q=8
Output: 6

Approach: If both p and q are less than root, go left. If both greater, go right. Otherwise, root is the LCA.

Complexity: Time O(h) · Space O(1)

28. Validate Binary Search Tree Medium

SuperdayTrees · DFSLeetCode:&#35;98

Check if a binary tree is a valid BST.

Input:  root=[5,1,4,null,null,3,6]
Output: false   (right child 4 < root 5)

Approach: DFS with (min, max) range validation for every node.

Complexity: Time O(n) · Space O(h)

Graphs & Dynamic Programming

29. Course Schedule — Cycle Detection Medium

SuperdayGraphs · Topological SortLeetCode:&#35;207

Given courses and prerequisites, determine if you can finish all courses (no cycle).

Approach: Topological sort via BFS (Kahn's). If all nodes processed, no cycle exists.

Complexity: Time O(V+E) · Space O(V+E)

30. Coin Change — Minimum Coins Medium

SuperdayDPLeetCode:&#35;322

Find the minimum number of coins to make up a given amount.

Input:  coins=[1,2,5], amount=11
Output: 3   (5+5+1)

Approach: Bottom-up DP. dp[i] = min(dp[i], dp[i-coin]+1) for each coin.

Complexity: Time O(amount×n) · Space O(amount)

31. Unique Paths in Grid Medium

SuperdayDP · GridLeetCode:&#35;62

Count all unique paths from top-left to bottom-right of an m×n grid moving only right or down.

Input:  m=3, n=7
Output: 28

Approach: dp[i][j] = dp[i-1][j] + dp[i][j-1]. Optimizable to a 1D array.

Complexity: Time O(m×n) · Space O(n)

32. Longest Increasing Subsequence Medium

SuperdayDP · Binary SearchLeetCode:&#35;300

Find the length of the longest strictly increasing subsequence.

Input:  [10,9,2,5,3,7,101,18]
Output: 4   ([2,3,7,101])

Approach: Binary search on tails[] array (patience sorting).

Complexity: Time O(n log n) · Space O(n)

GS Puzzle Round (Unique to Goldman Sachs)

Goldman Sachs is one of the few tech companies that includes puzzle questions (roughly 20% of interview time). These test mathematical reasoning and first-principles thinking.

33. The 100 Floors — 2 Egg Drop Problem Hard

Puzzle Round · GS ClassicMath · DPLeetCode:&#35;1884

You have 2 eggs and a 100-floor building. Find the minimum number of trials needed to determine the highest floor from which an egg can be dropped without breaking, in the worst case.

Answer: 14 trials
Why:    Drop from floor 14, then 27, 36, 44, 51, 57, 62, 66, 69, 71...
        (decreasing intervals: 14,13,12,11,10...)
        If egg 1 breaks at floor k, try floors k-gap+1 to k-1 with egg 2.

Approach: Let n be the number of trials. You want the maximum floors coverable with 2 eggs in n trials = n(n+1)/2. Solve for n such that n(n+1)/2 >= 100 → n=14.

Follow-up (DP version): Generalize to k eggs and n floors. dp[k][n] = min trials with k eggs and n floors.

34. Burning Rope — Measure 45 Minutes Hard

Puzzle Round · GS ReportedMath · Logic

You have two ropes that each burn in exactly 60 minutes (non-uniform burn rate). Using only matches, measure exactly 45 minutes.

Solution:
Step 1: Light rope 1 from BOTH ends, and rope 2 from ONE end simultaneously.
Step 2: Rope 1 burns out in 30 minutes (both ends burning).
Step 3: At the 30-minute mark, light the OTHER end of rope 2.
Step 4: Rope 2 had 30 minutes left, so it now burns in 15 more minutes.
Total: 30 + 15 = 45 minutes.

Key insight: Burning a rope from both ends halves its remaining burn time regardless of non-uniformity.

35. Poisoned Wine — Minimum Test Strips Hard

Puzzle Round · GS ClassicMath · Binary Representation

You have 1000 wine bottles, one of which is poisoned. You have 10 test strips and 1 hour. A strip shows positive after 30 mins if it contacts poison. What is the minimum number of strips needed to identify the poisoned bottle?

Answer: 10 strips (can identify up to 2^10 = 1024 bottles)
Strategy: Assign each bottle a unique 10-bit binary number.
          Strip i gets a drop from every bottle whose binary number has bit i = 1.
          After 30 mins, the pattern of positive strips gives the binary number of the poisoned bottle.

Key insight: Encode each bottle as a binary number. The result pattern directly decodes to the poisoned bottle index.

Additional High-Frequency Questions

36. Two Sum Easy

All RoundsArrays · HashingLeetCode:&#35;1
Input: nums=[2,7,11,15], target=9 → Output: [0,1]

Approach: Hash map: store each number's index. For each element, check if target-num exists. Time O(n).

37. 3Sum Medium

SuperdayArrays · Two PointersLeetCode:&#35;15

Find all unique triplets summing to zero. Sort + two pointers. Time O(n²).

38. Top K Frequent Elements Medium

SuperdayHeaps · HashingLeetCode:&#35;347
Input: nums=[1,1,1,2,2,3], k=2 → Output: [1,2]

Approach: Frequency map + min-heap of size k. Time O(n log k).

39. Word Break Medium

SuperdayDP · StringsLeetCode:&#35;139

Can s be segmented into dictionary words? DP: dp[i] = true if s[0..i-1] segments cleanly. Time O(n²).

40. Maximum Subarray (Kadane's) Medium

All RoundsArrays · DPLeetCode:&#35;53
Input: [-2,1,-3,4,-1,2,1,-5,4] → Output: 6 ([4,-1,2,1])

Approach: Kadane's — track curSum and maxSum. If curSum < 0, reset to 0. Time O(n).

41. Implement Queue using Stacks Easy

Superday · OOP FocusStack · DesignLeetCode:&#35;232

Implement a FIFO queue using only two stacks.

Approach: Two stacks in and out. Push always to in. On pop/peek, if out is empty, transfer all from in. Amortized O(1).

Why GS asks this: Tests understanding of abstract data types and amortized complexity — important for their Java-heavy codebase.

42. Find Median from Data Stream Hard

Superday · Finance RelevantHeaps · DesignLeetCode:&#35;295

Dynamically maintain a median as numbers are added. Max-heap (lower half) + min-heap (upper half). O(log n) add, O(1) median.

43. Decode Ways Medium

SuperdayDP · StringsLeetCode:&#35;91

Count ways to decode a digit string where A=1...Z=26. DP: dp[i] adds dp[i-1] for single-digit and dp[i-2] for valid two-digit. Time O(n).

44. Search in Rotated Sorted Array Medium

SuperdayBinary SearchLeetCode:&#35;33
Input: nums=[4,5,6,7,0,1,2], target=0 → Output: 4

Approach: Modified binary search — determine which half is sorted, check if target lies in it, then search accordingly. Time O(log n).

45. Generate Parentheses Medium

SuperdayBacktracking · StringsLeetCode:&#35;22

Generate all valid combinations of n pairs of parentheses. Backtracking: add ( if open < n, add ) if close < open.

46. Clone Graph Medium

SuperdayGraphs · DFSLeetCode:&#35;133

Deep copy a connected undirected graph. DFS + hash map (original → clone). Time O(V+E).

47. Maximal Square Medium

SuperdayDP · MatrixLeetCode:&#35;221

Find the largest square of '1's in a binary matrix. dp[i][j] = min(top, left, diag) + 1. Time O(m×n).

48. Pacific Atlantic Water Flow Medium

SuperdayGraphs · BFSLeetCode:&#35;417

Find cells from which water can flow to both oceans. Reverse BFS from both borders. Answer = intersection.

49. Next Permutation Medium

SuperdayArraysLeetCode:&#35;31

Rearrange to the next lexicographically greater permutation in-place.

[1,2,3] → [1,3,2]     [3,2,1] → [1,2,3]

Find rightmost descending point, swap with smallest larger element to its right, reverse the suffix. Time O(n).

50. Edit Distance Hard

SuperdayDP · StringsLeetCode:&#35;72

Minimum insert/delete/replace to convert word1 to word2.

"horse" → "ros" = 3 operations

2D DP. If chars match: dp[i-1][j-1], else 1 + min(insert, delete, replace). Time O(m×n).

Preparation Tips

  • Java is preferred at GS: Unlike most product companies, Goldman Sachs heavily uses Java. Practice in Java — know ArrayList vs LinkedList, TreeMap vs HashMap, PriorityQueue, and thread safety basics.
  • Puzzle round is real: Prepare 5–7 classic puzzles (egg drop, coin weighing, burning ropes, pirates and gold). These are not trick questions — GS wants to see structured reasoning.
  • OA has MCQs too: Brush up on time complexities, OOP principles (SOLID), basic SQL (JOIN, GROUP BY), and OS concepts (threading, memory).
  • Finance context matters: GS interviewers appreciate it when you connect solutions to finance. If asked about a streaming median, mention order book pricing. If asked about graphs, think trade dependency networks.
  • CoderPad tip: Unlike a Google Doc, CoderPad has syntax highlighting and can run code. Use this advantage — test with examples before submitting. GS interviewers do check correctness.
  • Superday pacing: You will have 3–5 consecutive interviews. Manage your energy. It's fine to take 30 seconds to think before answering. Slow and correct beats fast and wrong.