Salesforce Coding Interview Questions
100 Salesforce coding interview problems with full optimal solutions — 30 easy, 50 medium, 20 hard. Every problem ships with multiple approaches (brute-force first, then the optimal), complexity tables for each, company-specific tips on what an Salesforce interviewer values, and a FAQ section.
Showing 61 problems of 100
- #4easysometimes asked
4. Remove Duplicates from Sorted Array
Remove duplicates from a sorted array in place and return the new length. Salesforce asks this to verify you can manage two pointers cleanly — they use the same pattern in their dedup logic for record imports.
- #5easysometimes asked
5. Remove Element
Remove all occurrences of a value from an array in place. Salesforce uses this to test in-place array manipulation, the same pattern they use in their record-filtering pipelines.
- #6easysometimes asked
6. Search Insert Position
Find the index to insert a target value into a sorted array. Salesforce uses this to test whether you implement binary search with the correct boundary semantics — the same pattern their SOQL ORDER-BY range queries depend on.
- #7easyrarely asked
7. Plus One
Increment a number represented as an array of digits by one. Salesforce asks this to verify you handle carry propagation cleanly — a building block for their financial-precision arithmetic.
- #9easysometimes asked
9. Binary Tree Inorder Traversal
Return the inorder traversal of a binary tree. Salesforce uses this to test both recursive and iterative tree traversal, since their org-hierarchy queries (e.g., role hierarchy) rely on tree walks.
- #10easysometimes asked
10. Same Tree
Determine if two binary trees are identical in structure and value. Salesforce uses this to test recursive tree comparison, which underlies their metadata-diff and config-deployment pipelines.
- #11easysometimes asked
11. Symmetric Tree
Determine if a binary tree is a mirror of itself around its center. Salesforce uses this to test mirrored recursion — the key insight that the recursive subproblem differs from the surface problem.
- #13easysometimes asked
13. Balanced Binary Tree
Determine if a binary tree is height-balanced (every node's left and right subtree differ in height by at most 1). Salesforce uses this to test the bottom-up pattern that avoids the O(n^2) trap.
- #14easysometimes asked
14. Path Sum
Determine if a binary tree has a root-to-leaf path summing to a target value. Salesforce uses this to test recursive path tracking, the foundation of their workflow-rule cascade evaluation.
- #15easyrarely asked
15. Pascal's Triangle
Given numRows, return the first numRows of Pascal's triangle. Salesforce asks this to test row-by-row dynamic-programming style construction.
- #17easysometimes asked
17. Valid Palindrome
Determine if a string is a palindrome considering only alphanumeric characters and ignoring case. Salesforce uses this to test two-pointer string manipulation with edge-case handling.
- #21easysometimes asked
21. Two Sum II - Input Array Is Sorted
Find two indices in a sorted array that sum to a target, using O(1) space. Salesforce uses this to test the two-pointer pattern that exploits sortedness.
- #22easysometimes asked
22. Majority Element
Find the element that appears more than n/2 times in an array. Salesforce asks this to test the Boyer-Moore voting algorithm, an O(1)-space trick that surprises most candidates.
- #23easysometimes asked
23. Rotate Array
Rotate an array to the right by k steps. Salesforce uses this to test the three-reverse trick that achieves O(1) extra space.
- #24easyrarely asked
24. Reverse Bits
Reverse the bits of a given 32-bit unsigned integer. Salesforce uses this to gauge whether candidates can comfortably reason about bit manipulation.
- #25easysometimes asked
25. Number of 1 Bits
Count the number of set bits (1s) in a 32-bit unsigned integer. Salesforce uses this to test the Brian Kernighan bit-trick used internally in their permission-mask aggregation.
- #27easyrarely asked
27. Happy Number
Determine if a number is 'happy' — repeatedly replace with sum of squares of its digits until it reaches 1 (happy) or cycles forever. Salesforce uses this to test cycle detection in a synthesized sequence.
- #28easysometimes asked
28. Isomorphic Strings
Determine if two strings are isomorphic (bijective character mapping). Salesforce uses this to test bidirectional hash-map invariants — they grade on whether you check BOTH directions.
- #33mediumsometimes asked
33. Longest Palindromic Substring
Return the longest palindromic substring in s. Salesforce uses this to test the expand-around-center pattern — they expect a clean O(n^2) solution.
- #34mediumsometimes asked
34. Container With Most Water
Find two lines that, with the x-axis, form a container holding the most water. Salesforce uses this to test the converging two-pointer pattern with an optimality argument.
- #36mediumsometimes asked
36. Letter Combinations of a Phone Number
Given a string of digits 2-9, return all possible letter combinations from a phone keypad. Salesforce uses this as the canonical backtracking warmup.
- #37mediumsometimes asked
37. Remove Nth Node From End of List
Remove the nth node from the end of a linked list in one pass. Salesforce uses this to test the two-pointer gap technique that avoids a second pass.
- #38mediumsometimes asked
38. Generate Parentheses
Given n pairs of parentheses, generate all combinations of well-formed parentheses. Salesforce uses this as a constrained-backtracking problem.
- #39mediumrarely asked
39. Swap Nodes in Pairs
Swap every two adjacent nodes in a linked list. Salesforce uses this to test pointer dexterity — they want clean iterative code without value swaps.
- #40mediumrarely asked
40. Next Permutation
Compute the next lexicographic permutation of an array in place. Salesforce uses this to test in-place array manipulation with a non-obvious algorithm.
- #43mediumsometimes asked
43. Valid Sudoku
Validate a Sudoku board's rows, columns, and 3x3 sub-boxes. Salesforce uses this to test multi-dimensional validation in a single pass.
- #44mediumsometimes asked
44. Combination Sum
Find all unique combinations of candidates that sum to target (candidates can be reused). Salesforce uses this as the canonical backtracking-with-reuse problem.
- #46mediumsometimes asked
46. Rotate Image
Rotate an n x n 2D matrix 90 degrees clockwise in place. Salesforce uses this to test the transpose-then-reverse trick that avoids the layer-by-layer approach.
- #49mediumsometimes asked
49. Spiral Matrix
Return all elements of a matrix in spiral order. Salesforce uses this to test boundary tracking and clean iteration when corners get tricky.
- #50mediumsometimes asked
50. Jump Game
Determine if you can reach the last index of an array where each element is the max jump distance. Salesforce uses this as the canonical greedy problem.
- #52mediumsometimes asked
52. Unique Paths
Count unique paths in an m x n grid moving only right or down. Salesforce uses this as a canonical 2D DP problem.
- #53mediumsometimes asked
53. Minimum Path Sum
Find the path from top-left to bottom-right of a grid with minimum sum. Salesforce uses this to test 2D DP with grid traversal.
- #54mediumrarely asked
54. Simplify Path
Convert a Unix-style file path to its canonical form. Salesforce uses this to test stack-based string processing — analogous to their record-hierarchy canonicalization.
- #55mediumsometimes asked
55. Edit Distance
Compute the minimum number of insertions, deletions, or substitutions to transform one string into another. Salesforce uses this as the canonical 2D DP problem with three-way transitions.
- #56mediumsometimes asked
56. Set Matrix Zeroes
Set entire rows and columns to zero where a zero exists in the matrix. Salesforce uses this to test in-place algorithms with O(1) space.
- #57mediumsometimes asked
57. Search a 2D Matrix
Search for a target in a row-wise and column-wise sorted matrix where each row's first is greater than the previous row's last. Salesforce uses this to test treating a 2D matrix as a 1D sorted array for binary search.
- #58mediumsometimes asked
58. Sort Colors
Sort an array of 0s, 1s, and 2s in-place. Salesforce uses this to test the Dutch National Flag (DNF) three-way partitioning algorithm.
- #59mediumsometimes asked
59. Combinations
Return all possible combinations of k numbers chosen from 1..n. Salesforce uses this as a backtracking template — relevant to their permission-set selection logic.
- #61mediumsometimes asked
61. Word Search
Determine if a word can be found in a 2D grid via adjacent cells (no revisits). Salesforce uses this to test DFS with backtracking and visited state.
- #62mediumsometimes asked
62. Decode Ways
Count the number of ways to decode a string of digits (1-26 → A-Z). Salesforce uses this to test DP with conditional transitions.
- #65mediumsometimes asked
65. Binary Tree Zigzag Level Order Traversal
Return the zigzag (alternating left-to-right, right-to-left) level-order traversal of a binary tree. Salesforce uses this as a BFS variant.
- #66mediumsometimes asked
66. Construct Binary Tree from Preorder and Inorder Traversal
Reconstruct a binary tree given its preorder and inorder traversals. Salesforce uses this to test recursive tree construction with index management.
- #69mediumsometimes asked
69. Find Peak Element
Find any peak (local maximum) in an array in O(log n). Salesforce uses this to test binary search on a non-monotonic predicate.
- #77mediumsometimes asked
77. Word Pattern
Determine if a string follows the same pattern as a sequence of words. Salesforce uses this to test bidirectional hashmap invariants in a more complex setting.
- #78mediumsometimes asked
78. Longest Increasing Subsequence
Find the length of the longest strictly increasing subsequence. Salesforce uses this as the canonical DP-with-binary-search optimization.
- #80mediumsometimes asked
80. Insert Delete GetRandom O(1)
Design a data structure supporting insert, delete, and getRandom all in O(1). Salesforce uses this as the canonical 'when do you need both array and map' problem.
- #81hardsometimes asked
81. Median of Two Sorted Arrays
Find the median of two sorted arrays in O(log(min(m, n))). Salesforce uses this as a stretch question to gauge advanced binary-search mastery.
- #82hardrarely asked
82. Regular Expression Matching
Implement regular expression matching with '.' and '*'. Salesforce uses this as a 2D-DP stress test — they grade on whether you can handle the star's variable-length match.
- #84hardrarely asked
84. Reverse Nodes in k-Group
Reverse every k consecutive nodes in a linked list, leaving the trailing remainder untouched. Salesforce uses this as a pointer-acrobatics stress test.
- #85hardrarely asked
85. Substring with Concatenation of All Words
Find all starting indices where a concatenation of all given words appears. Salesforce uses this as an advanced sliding-window with multiplicity tracking.
- #86hardrarely asked
86. Longest Valid Parentheses
Find the longest valid (well-formed) parentheses substring. Salesforce uses this as a stack/DP hybrid that tests both approaches.
- #87hardsometimes asked
87. First Missing Positive
Find the smallest positive integer missing from an unsorted array in O(n) time and O(1) space. Salesforce uses this as an O(1)-space cyclic-sort stress test.
- #89hardrarely asked
89. Wildcard Matching
Implement wildcard pattern matching with '?' and '*'. Salesforce uses this in their permission-set glob matching for object access rules.
- #90hardrarely asked
90. Jump Game II
Find the minimum number of jumps to reach the last index. Salesforce uses this as a greedy stress test — they grade on the BFS-level insight.
- #91hardrarely asked
91. N-Queens
Place n queens on an n x n chessboard so no two attack each other; return all distinct solutions. Salesforce uses this as the canonical hard backtracking problem.
- #92hardrarely asked
92. N-Queens II
Count the number of distinct N-queens placements without returning the actual boards. Salesforce uses this to test whether you can specialize an enumeration algorithm.
- #94hardrarely asked
94. Valid Number
Determine if a string represents a valid number. Salesforce uses this to test edge-case enumeration and finite-state-machine reasoning.
- #95hardrarely asked
95. Text Justification
Format text such that each line has exactly maxWidth characters with full justification. Salesforce uses this as a string-manipulation stress test.
- #97hardsometimes asked
97. Largest Rectangle in Histogram
Find the largest rectangle in a histogram. Salesforce uses this as the canonical monotonic-stack problem.
- #98hardrarely asked
98. Maximal Rectangle
Find the largest rectangle of 1s in a binary matrix. Salesforce uses this to test the row-by-row histogram reduction.
- #100hardrarely asked
100. Word Ladder
Find the shortest transformation sequence from beginWord to endWord changing one letter at a time. Salesforce uses this as a BFS-on-implicit-graph stress test.
Related interview-prep guides
HireVue Tech Interview Guide: The 2026 Playbook for Async Video Rounds
HireVue is the category-leading async video interview platform. Candidates record answers solo, on the clock, and a combined AI-plus-human review layer scores the recording days later. For 2026 tech jobseekers, the format is different enough from live interviews to need its own playbook. This guide is that playbook.
Codility for Tech Interviews in 2026: The Complete Guide for Candidates
Codility is the dominant algorithmic-assessment platform across European tech hiring. Heavy in the UK, Germany, Netherlands, Nordics, and Poland where the company was founded. It scores candidates on both correctness and time complexity, runs 60-to-120-minute timed tests, and ships three products: Tests, CodeCheck, and CodeLive. This guide is what 2026 candidates need to know.
Spark Hire Async Video Interview Guide for Tech Jobseekers (2026)
Spark Hire is a mid-market async video interview platform used by 6,000+ employers across tech, healthcare, retail, and education. Candidates record video answers to pre-recorded prompts within configurable time budgets, and hiring teams review the recordings asynchronously. Lighter on AI scoring than HireVue, heavier on human review.