FastPrepLast Candidate Standing
Problems/Last Candidate Standing

Last Candidate Standing

Goldman Sachs logoGoldman Sachs● MediumFULLTIMEPHONE SCREEN

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: A recovered Goldman Sachs screening report describes candidates in a circle, where one is eliminated after every k hops until one remains. It does not say how people are numbered or what the first count is. This version uses the usual 1-based Josephus setup. Our version is about 92% the same as the reported question.

Candidates numbered 1 through n stand in a circle. Starting at candidate 1, repeatedly count k remaining candidates, including the current candidate as count one. Eliminate the candidate counted as k, then continue from the next remaining candidate.

Return the number of the final candidate.

Function

lastCandidateStanding(n: int, k: int) → int

Examples

Example 1

n = 5k = 2return = 3

Candidates 2, 4, 1, and 5 are eliminated, leaving 3.

Example 2

n = 7k = 3return = 4

The standard Josephus recurrence leaves candidate 4.

Constraints

  • 1 <= n <= 10000000
  • 1 <= k <= 10^9

More Goldman Sachs Phone Screen questions

  • Best Average Student ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
  • Design Hash MapOA · PHONE SCREEN · Seen Nov 2026
  • House Robber IIIPHONE SCREEN · Seen Nov 2026
  • Trapping Rain WaterPHONE SCREEN · Seen Nov 2026
  • Check a Complete Binary TreePHONE SCREEN · Seen Oct 2026
  • Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
  • Count Staircase WaysPHONE SCREEN · Seen Oct 2026
  • Is a Power of TenPHONE SCREEN · Seen Oct 2026
  • Minimum Traveling Salesperson TourPHONE SCREEN · Seen Oct 2026
  • Square Root with Newton IterationPHONE SCREEN · Seen Oct 2026

Similar questions at other companies

  • Sliding Window Attention over a KV CacheNVIDIA · PHONE SCREENNVIDIA interview questions
  • Constant-Time Weighted Pick with an Alias TableEtched · PHONE SCREEN
  • Monthly Calendar with Custom Week StartStripe · PHONE SCREENStripe interview questions
  • Fractional Share Inventory FlatteningRobinhood · PHONE SCREEN · ONSITE INTERVIEWRobinhood interview questions
  • Logistic Regression DiagnosticsLinkedIn · PHONE SCREENLinkedIn interview questions
  • Evenly Schedule Vehicle InspectionsAmazon · PHONE SCREEN
  • Implement Cross-Entropy LossOpenAI · PHONE SCREENOpenAI interview questions
  • Cumulative No-Intercept Regression BetasCitadel · PHONE SCREENCitadel interview questions
  • Add Signed Character ArraysByteDance · PHONE SCREENByteDance interview questions
  • Per-Segment SpeedingOnePay · PHONE SCREENOnePay interview questions
All Goldman Sachs interview questionsSee Goldman Sachs hiring insights
Saved
class Solution {
    public int lastCandidateStanding(int n, int k) {
      // write your code here
    }
}
Checking account…