Reported July 2024
Salesforcesliding window

Same Substring

Reported by candidates from Salesforce's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Salesforce OA. Under 2s to a working solution.
Founder's read

Salesforce's Same Substring problem landed in July 2024 and it's a sliding-window play you've probably seen before in some form. You get a string (or two strings), and the task is to find the longest contiguous substring that satisfies some equality or matching condition. The trick isn't the algorithm, it's parsing what "same" actually means in their specific test cases. StealthCoder will read the exact problem statement live and match it to the pattern instantly if you blank.

Pattern and pitfall

This is a classic sliding-window problem. You maintain a left and right pointer, expand the window by moving right, and shrink from the left when the condition breaks. The gotcha: candidates often misread whether you're comparing character frequencies, checking if two substrings are identical, or validating some property across the window. Common pitfall is forgetting to track the max length as you expand, or shrinking too aggressively. The pattern is O(n) time, O(1) or O(26) space depending on whether you use a frequency map for letters. If you hit a wall during the live OA, StealthCoder catches the exact wording and feeds you the right approach while the proctor sees nothing.

The honest play: practice the pattern, and have StealthCoder ready for the one you didn't see coming.

If this hits your live OA

You can drill Same Substring cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as longest substring without repeating characters. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Salesforce's OA.

Salesforce reuses patterns across OAs. Built for the candidate who saw this exact problem leak two days before his OA and wondered if anyone had a play. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Same Substring FAQ

Is this asking me to find two identical substrings or one substring with a property?+

Without the full problem text, it could be either. Read carefully: if it says "find substrings that are the same," you might need to compare two windows. If it says "find a substring where characters repeat equally," that's a frequency check. Salesforce often hides the trick in the phrasing.

Do I need a hash map or can I solve this with just pointers?+

Pointers alone work if you're just expanding and shrinking. A hash map (or character count array) is needed if you're tracking frequencies or comparing substrings. Start with pointers, optimize with a map if you TLE.

What's the most common mistake on this problem?+

Expanding the window but forgetting to update your answer before shrinking. Also, not resetting your frequency map correctly when the window shrinks. Trace through a small example by hand first.

Is this sliding-window always O(n)?+

Yes, each pointer crosses the string once. The real cost is the operations inside the loop. If you're comparing full substrings character by character, that's O(n^2). Use a hash or rolling hash to stay O(n).

How do I prepare for this in 24 hours if I've never seen sliding window?+

Learn the two-pointer template: expand right, check condition, shrink left if condition fails, track max. Practice on LeetCode 3 (Longest Substring Without Repeating Characters) or 438 (Find All Anagrams). That's the pattern Salesforce uses.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Salesforce.

OA at Salesforce?
Invisible during screen share
Get it