Salesforce DS & Algo Round Interview Questions Asked in 2026
DS & Algo questions for this list have been picked from Salesforce interview experiences shared on forums/blogs etc in 2026. Use this list for final preparation of your Salesforce interview rounds.
Salesforce hires for Member of Technical Staff i.e. MTS/SMTS/LMTS positions. MTS role is around 3 years experience. LLD rounds may be there for MTS role as well.
Complete list of Salesforce DS and Algo round questions:
https://codezym.com/lld/salesforce-dsa
If you are looking for Salesforce low level design round questions, then you can find them here:
LeetCode Questions
Below is list of questions you can directly find on LeetCode (free ones):
Insert Delete GetRandom O(1)
https://leetcode.com/problems/insert-delete-getrandom-o1/descriptionCoin Change II
https://leetcode.com/problems/coin-change-ii/description/Maximal Square
https://leetcode.com/problems/maximal-square/description/Maximal Rectangle
https://leetcode.com/problems/maximal-rectangle/description/Rotting Oranges
https://leetcode.com/problems/rotting-oranges/Course Schedule II
https://leetcode.com/problems/course-schedule-ii/description/LRU Cache
https://leetcode.com/problems/lru-cache/description/LFU Cache
https://leetcode.com/problems/lfu-cache/description/Lowest Common Ancestor of a Binary Tree
https://leetcode.com/problems/lowest-common-ancestor-of-a-binary-tree/description/Number of Islands
https://leetcode.com/problems/number-of-islands/description/Find Median from Data Stream
https://leetcode.com/problems/find-median-from-data-stream/description/Implement Trie (Prefix Tree)
https://leetcode.com/problems/implement-trie-prefix-tree/description/String Compression
https://leetcode.com/problems/string-compression/description/Time Needed to Rearrange a Binary String
https://leetcode.com/problems/time-needed-to-rearrange-a-binary-string/description/Minimum Operations to Reduce an Integer to 0
https://leetcode.com/problems/minimum-operations-to-reduce-an-integer-to-0/description/Top K Frequent Words
https://leetcode.com/problems/top-k-frequent-words/description/Merge Intervals
https://leetcode.com/problems/merge-intervals/description/Intersection of Two Linked Lists
https://leetcode.com/problems/intersection-of-two-linked-lists/description/Partition Array Into Two Arrays to Minimize Sum Difference
https://leetcode.com/problems/partition-array-into-two-arrays-to-minimize-sum-difference/description/Reorganize String
https://leetcode.com/problems/reorganize-string/description/Combination Sum II
https://leetcode.com/problems/combination-sum-ii/description/Remove All Adjacent Duplicates in String II
https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii/description/First Missing Positive
https://leetcode.com/problems/first-missing-positive/description/Unique Email Addresses
https://leetcode.com/problems/unique-email-addresses/description/All O`one Data Structure
https://leetcode.com/problems/all-oone-data-structure/description/Longest Substring without Repeating Characters
https://leetcode.com/problems/longest-substring-without-repeating-characters/Time Based Key-Value Store
https://leetcode.com/problems/time-based-key-value-store/Pairs of Songs with Total Durations Divisible by 60
https://leetcode.com/problems/pairs-of-songs-with-total-durations-divisible-by-60/description/Asteroid Collision
https://leetcode.com/problems/asteroid-collision/description/Longest Substring of All Vowels in Order
https://leetcode.com/problems/longest-substring-of-all-vowels-in-order/description/Zigzag Conversion
https://leetcode.com/problems/zigzag-conversion/description/Letter Combinations of a Phone Number
https://leetcode.com/problems/letter-combinations-of-a-phone-number/description/Search in Rotated Sorted Array
https://leetcode.com/problems/search-in-rotated-sorted-array/description/Path with Maximum Gold
https://leetcode.com/problems/path-with-maximum-gold/description/House Robber II
https://leetcode.com/problems/house-robber-ii/description/Basic Calculator II
https://leetcode.com/problems/basic-calculator-ii/description/Good Ways to Split an Array in 3 Contiguous Parts
You are given a List<Integer> nums containing non-negative integers. Split the list into three non-empty contiguous parts: A1, A2, and A3.
Let:
S1 be the sum of elements in A1
S2 be the sum of elements in A2
S3 be the sum of elements in A3
Count how many splits are valid such that:
S2 ≤ S1 + S3
https://codezym.com/question/248-good-ways-to-split-arrayATM Queue Leaving Order
There are n people standing in an ATM queue, numbered from 1 to n. Initially, they stand in increasing order of their number.
Person i wants to withdraw amounts[i - 1] units of money. In one turn, a person can withdraw at most maxWithdraw units.
If a person still needs more money after their turn, they go to the end of the queue. Otherwise, they leave the queue.
Return the order in which all people leave the queue.
https://codezym.com/question/249-atm-queue-leaving-orderMinimum Knight Moves on Infinite Chessboard
A knight is placed at coordinate [0, 0] on an infinite chessboard. The board has no boundary, so coordinates may be positive or negative.
In a single move, the knight travels two squares along one axis and one square along the other axis. Given a target coordinate [x, y], return the fewest moves needed for the knight to reach that target.
https://codezym.com/question/250-min-knight-moves-chessSerialize Nearly Sorted Stream of Numbers
You are given a stream of numbers and an integer bufferSize. Every number is at most bufferSize positions away from where it should appear in the correctly ordered stream.
Return the numbers in sorted order, meaning the final list should be in non-decreasing order.
If two numbers are equal, keep their relative order from the input stream to make the output deterministic.
https://codezym.com/question/251-serialize-nearly-sorted-streamMinimum Meeting Rooms Required
You are given a list of meeting time intervals.
Each interval is provided as a string in the format "start,end", where start is the meeting start time and end is the meeting end time. You need to split each interval string and extract the integer values start and end.
Each interval is half-open, represented as [start, end). This means a meeting ending at time x does not overlap with another meeting starting at time x. For example, [1, 3) does not overlap with [3, 5).
Your task is to determine the minimum number of meeting rooms required so that no two overlapping meetings are placed in the same meeting room.
https://codezym.com/question/179-minimum-meeting-rooms-requiredRotting Oranges With Different Connection Times
You are given a grid of oranges and a list of connection times between adjacent cells. Each cell contains one of the following values:
0: an empty cell
1: a fresh orange
2: a rotten orange
A rotten orange can make a connected fresh orange rotten, but each connection may take a different amount of time. A connection is given as "row1,col1,row2,col2,time", meaning the cell at [row1, col1] and the cell at [row2, col2] are connected, and rotting can spread across this connection in time minutes.
Since different connections may take different amounts of time, rotting should always use the earliest possible time at which each orange can become rotten.
Return the minimum time needed for all fresh oranges to become rotten.
https://codezym.com/question/252-rotting-oranges-weightedCount Ways to Split String Into Prime Numbers
You are given a string s that represents a positive integer. Count the number of ways to split s into one or more prime numbers.
The digits must remain in the same order, and every digit of s must be used exactly once. Each split part must represent a prime number.
A prime number is an integer greater than 1 that has exactly two positive divisors: 1 and itself.
https://codezym.com/question/253-count-ways-to-split-to-prime-numbersToken Bucket Resource Allocation
You are given a token bucket with a fixed number of tokens. Users can request tokens from the bucket. A request is granted only when enough tokens are currently available.
When a request is granted, that user holds those tokens for exactly 1 hour. After 1 hour, the tokens expire automatically and return to the bucket.
A user may also manually release all currently active tokens held by them before expiry. Expired tokens must be cleaned up before processing every method call.
https://codezym.com/question/255-token-bucket-resource-allocationMaximum Requests in Continuous Time Window
You are given a list timestamp, where each value represents the minute at which one request occurred. You are also given an integer windowSize. Return the maximum number of requests that can be found inside any continuous time window of length windowSize minutes.
The timestamps may be given in any order. The method should count requests based on their time values, not their original positions.
https://codezym.com/question/256-max-requests-continuous-time-windowMinimum Time Task Scheduling with Constraints
You are given a list of task types, a list of memory required by each task, and a server memory limit. Each task takes exactly 1 unit of time to complete.
In one unit of time, multiple tasks can run together if they satisfy both constraints: at most 2 tasks of the same type can run in parallel, and the total memory of all running tasks must not exceed the server memory limit.
Return the minimum time required to execute all tasks.
https://codezym.com/question/258-min-time-task-schedulingGrid With K Jumps Minimum Steps
You are given an m x n grid. Each cell is either empty or blocked by an obstacle. From any empty cell, you may move in one of four directions: left, right, up, or down.
In one step, you may jump from 1 to k cells in the chosen direction. Every cell crossed during the jump, including the landing cell, must be inside the grid and must not be an obstacle.
Return the minimum number of steps required to reach the destination cell from the source cell. If the destination cannot be reached, return -1.
https://codezym.com/question/259-grid-with-k-jumpsCount Number of Distinct Islands in Grid
You are given a non-empty grid containing only 0 and 1.
Each 1 represents land, and each 0 represents water.
An island is a connected group of land cells. Two land cells are connected if they share a side horizontally or vertically.
You may assume that all four outer edges of the grid are surrounded by water.
Your task is to count how many distinct island shapes exist in the grid.
Two islands are considered the same only if one island can be shifted up, down, left, or right to exactly match the other island.
Rotating or reflecting an island is not allowed when comparing island shapes.
https://codezym.com/question/190-count-distinct-islands-gridBottle Recycling Perk Maximization
You are given an initial number of bottles and an initial amount of money. You may either recycle bottles to earn money or spend bottles and money to buy perks.
Recycling one bottle gives recycleVal dollars. Buying one perk costs exactly 1 bottle and perkVal dollars.
Each bottle can be used at most once. A bottle that is recycled cannot be used to buy a perk, and a bottle used to buy a perk cannot be recycled. Return the maximum number of perks that can be obtained.
https://codezym.com/question/260-bottle-recycling-perk-maximizationMaximum Number of Non-Overlapping Palindromic Substrings
You are given a string s and an integer k. Choose the maximum possible number of non-overlapping substrings such that every chosen substring is a palindrome and has length at least k.
A palindrome is a string that reads the same from left to right and from right to left.
The chosen substrings do not need to cover the entire string. Characters between chosen substrings and any remaining characters may be ignored.
Return the chosen palindromic substrings as a List<String>. The substrings must be returned in the same left-to-right order in which they appear in s.
https://codezym.com/question/261-max-non-overlapping-palindromesCount Special Subarrays With Odd Divisors
You are given a list of positive integers called nums. A contiguous subarray is considered special when the product of all its elements has an odd number of positive divisors.
Return the total number of special subarrays in nums.
https://codezym.com/question/262-count-special-subarraysMaximum Length Subsequence Substring
You are given two strings, x and y. Return the longest string that is both a subsequence of x and a contiguous substring of y.
A subsequence is formed by deleting zero or more characters without changing the order of the remaining characters. A substring consists of consecutive characters.
If multiple valid strings have the maximum length, return the lexicographically smallest one. If no non-empty valid string exists, return an empty string.
https://codezym.com/question/263-max-length-subseq-substringIPO Share Allocation With Bids
You are given a collection of bids for shares in an IPO and the total number of shares available. Allocate the shares according to bid price and submission time, then return the user IDs of bidders who receive no shares.
https://codezym.com/question/264-ipo-share-allocation-with-bidsPurchase Maximum Number of Consecutive Products
You are given a list of product prices sorted in non-decreasing order and a list of buying queries. For each query, determine the maximum number of consecutive products that can be purchased without exceeding the given budget.
https://codezym.com/question/265-purchase-max-consecutive-productsComplete Weekly Work Hours
A worker's daily hours for one week are represented by a seven-character string workHours. Each position corresponds to one day and contains either a digit from 0 to 9 or the character #.
Replace every # with a digit from 0 to 9 so that the sum of all seven digits is exactly requiredHours. Return all completed strings that satisfy this condition.
https://codezym.com/question/267-complete-weekly-work-hours