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 50 problems of 100
- #31mediumfrequently asked
31. Add Two Numbers
Add two numbers represented as linked lists (digits in reverse order). Salesforce asks this to test carry propagation and dummy-head pattern application together.
- #32mediumfrequently asked
32. Longest Substring Without Repeating Characters
Find the length of the longest substring without repeating characters. Salesforce uses this as the canonical sliding-window introduction — they grade on left-pointer correctness.
- #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.
- #35mediumfrequently asked
35. 3Sum
Find all unique triplets in an array that sum to zero. Salesforce uses this to test sort + two-pointer + dedup composition — a real Salesforce engineer must combine all three.
- #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.
- #41mediumfrequently asked
41. Search in Rotated Sorted Array
Search for a target in a rotated sorted array in O(log n). Salesforce uses this to test modified binary search — they value the 'figure out which half is sorted' reasoning.
- #42mediumfrequently asked
42. Find First and Last Position of Element in Sorted Array
Find the first and last position of a target in a sorted array in O(log n). Salesforce uses this to test the lower_bound / upper_bound pattern, used in their SOQL index range queries.
- #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.
- #45mediumfrequently asked
45. Permutations
Return all permutations of a distinct-integer array. Salesforce uses this as the cleanest backtracking template — perfect for testing 'used' tracking.
- #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.
- #47mediumfrequently asked
47. Group Anagrams
Group strings that are anagrams of each other. Salesforce uses this to test canonical-form hashing — they want O(n*k) with a frequency-tuple key.
- #48mediumfrequently asked
48. Maximum Subarray
Find the contiguous subarray with the largest sum. Salesforce uses this to test Kadane's algorithm — the canonical O(n) DP and a forecasting-dashboard staple.
- #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.
- #51mediumfrequently asked
51. Merge Intervals
Merge overlapping intervals in a list. Salesforce uses this as a foundational scheduling problem — they use it directly in their calendar conflict-resolution and queue-coalescing logic.
- #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.
- #60mediumfrequently asked
60. Subsets
Return all possible subsets of a distinct-integer array. Salesforce uses this to test power-set enumeration via backtracking or bitmask.
- #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.
- #63mediumfrequently asked
63. Validate Binary Search Tree
Determine if a binary tree is a valid BST. Salesforce uses this to test the recursive-with-bounds pattern that catches the 'check parent only' trap.
- #64mediumfrequently asked
64. Binary Tree Level Order Traversal
Return the level-order (BFS) traversal of a binary tree's values. Salesforce uses this as the canonical BFS template — they use the level-tracking pattern in their org-hierarchy reports.
- #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.
- #67mediumfrequently asked
67. Word Break
Determine if a string can be segmented into a sequence of dictionary words. Salesforce uses this as the canonical DP-on-strings problem.
- #68mediumfrequently asked
68. LRU Cache
Design a Least-Recently-Used cache with O(1) get and put. Salesforce uses this as the canonical data-structure-design problem — they use LRU eviction in their platform cache layer.
- #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.
- #70mediumfrequently asked
70. Number of Islands
Count the number of connected components of 1s in a 2D grid. Salesforce uses this as the canonical grid-DFS/BFS problem.
- #71mediumfrequently asked
71. Course Schedule
Determine if all courses can be finished given prerequisite pairs (cycle detection in a directed graph). Salesforce uses this directly in their workflow-rule cycle detection.
- #72mediumfrequently asked
72. Implement Trie (Prefix Tree)
Implement a trie supporting insert, search, and startsWith. Salesforce uses tries in their autocomplete and SOQL keyword lookup.
- #73mediumfrequently asked
73. Kth Largest Element in an Array
Find the kth largest element in an unsorted array. Salesforce uses this as the canonical heap/quickselect problem.
- #74mediumfrequently asked
74. Lowest Common Ancestor of a Binary Tree
Find the lowest common ancestor (LCA) of two nodes in a binary tree. Salesforce uses this in their role-hierarchy queries — 'find the common manager between two reports.'
- #75mediumfrequently asked
75. Product of Array Except Self
Return an array where each element is the product of all other elements (no division allowed). Salesforce uses this to test prefix-products and the no-division trick.
- #76mediumfrequently asked
76. Meeting Rooms II
Find the minimum number of meeting rooms needed for a set of meetings with start/end times. Salesforce uses this in their Calendar app's room booking and resource allocation algorithms.
- #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.
- #79mediumfrequently asked
79. Top K Frequent Elements
Return the k most frequent elements. Salesforce uses this for top-k report queries — they grade on heap vs bucket-sort recognition.
- #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.
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.