These are Algorithms questions of the kind Salesforce actually asks — the patterns reported from Salesforce's AI-engineering rounds, where design trade-offs, scale and failure modes matter as much as definitions. Treat this page as a mock interview: say every answer out loud before revealing it. If one surprises you, the lesson behind it is linked at the bottom.
Salesforce Algorithms concept questions
Merge two sorted arrays where the first has exactly enough empty space at its end to hold the second — in place, O(m + n). What direction do you merge, and why?
Asked in
First bad version: versions 1..n; once a version is bad, all after it are bad. An API isBadVersion(v) is expensive. Find the first bad version with fewest calls.
Asked in
Salesforce Algorithms applied & hands-on questions
Sort [2, 0, 2, 1, 1, 0] of only 0s, 1s and 2s in ONE pass, in place — no counting sort's two passes, no library sort.
Asked in
How to use this page: Salesforce rarely asks something you've never seen — they ask a standard Algorithms concept and then push one level deeper ("why?", "what would you do if..."). Master the concept in the Algorithms course lessons, and the follow-up stops being scary.
Keep practising: Binary Search, Dynamic Programming, BFS & DFS and Patterns & Strategy cover what most Salesforce Algorithms rounds test.

