Check String Permutation
Updated
Problem statement
Given strings s and t, return true if rearranging all characters of s can produce exactly t. Otherwise return false.
Every occurrence matters. Comparisons are case-sensitive, and spaces and punctuation count as ordinary characters. Two empty strings are permutations of each other.
Validation follow-up
The callable task receives non-null strings. Discuss how a service should check input when it arrives:
- Reject null or unsupported input.
- Treat an empty string differently from a missing value.
- Test validation code that can be reused.
Explain how you would organize validators in production code.
Function
arePermutations(s: String, t: String) → booleanExamples
Example 1
s = "abbbb"t = "bbbba"return = trueBoth strings contain one a and four b characters.
Example 2
s = "abbbc"t = "aaabc"return = falseThe multiplicities of a and b differ.
Example 3
s = ""t = ""return = trueBoth strings have zero occurrences of every character.
Constraints
0 <= s.length, t.length <= 10^5.- Every character is printable ASCII with a code from
32through126. - Both inputs are non-null.
More Vanguard interview questions
- Two SumOA · Seen Sep 2026
- Valid ParenthesesOA · Seen Sep 2026
- Are They PangramsOA · Seen Nov 2025
- Missing WordsOA · Seen Nov 2025
- Spam DetectionOA · Seen Nov 2025
- Binge WatchingOA · Seen Jan 2023
- Minimum Moves Around a Circular ArrayOA · Seen Aug 2022
- Maximum Occurring CharacterOA · Seen Mar 2022
- Picking TicketsOA · Seen Mar 2022
- Tool List: Two Smallest ValuesOA · Seen Nov 2021
Similar questions at other companies
- Detect a Straight FlushTemu · PHONE SCREENTemu interview questions
- First Letter to Appear TwiceCisco · PHONE SCREENCisco interview questions
- Halfway Course in a Single TrackCrunchyroll · PHONE SCREENCrunchyroll interview questions
- Portfolio Valuation, Part 1Stripe · PHONE SCREENStripe interview questions
- Single-Condition Product FilterCrowdstrike · PHONE SCREENCrowdstrike interview questions
- Summarize Server Healthcheck LogsNVIDIA · PHONE SCREENNVIDIA interview questions
- Known Words Matching Phone DigitsLinkedIn · PHONE SCREENLinkedIn interview questions
- First Non-Repeated CharacterDell Technologies · PHONE SCREENDell Technologies interview questions
- Convert an Entry List to a MapEPAM · PHONE SCREENEPAM interview questions
- First Non-Repeating CharacterGoldman Sachs · PHONE SCREEN · ONSITE INTERVIEWGoldman Sachs interview questions