Interleave Two Strings
Updated
Problem statement
You are given two strings, first and second. Build a result by taking one character from first, then one from second, and repeating.
The first result character comes from first. When one string is exhausted, append the remaining suffix of the other string.
Function
interleaveStrings(first: String, second: String) → StringExamples
Example 1
first = "aaaaa"second = "bbb"return = "abababaa"The first six characters alternate, then the two unused characters from the first string are appended.
Example 2
first = ""second = "abc"return = "abc"The first string is empty, so the complete second string is appended.
Constraints
0 <= first.length,second.length <= 100000- Both strings contain lowercase English letters.
More ZipRecruiter Online Assessment questions
- Four-Level Banking System with Scheduled PaymentsOA · Seen Oct 2026
- Count Three-Digit Numbers with Distinct DigitsOA · Seen Oct 2024
- Longest Frequency-Bounded SubarrayOA · Seen Oct 2024
- Minimum Changes to Draw a YOA · Seen Oct 2024
- Apply Binary State OperationsOA · Seen Sep 2024
- Simulate Orchard Rot SpreadOA · Seen Sep 2024
- Compare Odd- and Even-Index SumsOA · Seen Sep 2024
- Coordinate Removals with Column GravityOA · Seen Sep 2024
- Lexicographically Smallest End ReversalOA · Seen Sep 2024
- Recursively Expanded Shell Command CountsOA · Seen Sep 2024
Similar questions at other companies
- Rearrange String by Alternating EndsHudson River Trading · OAHudson River Trading interview questions
- Alternate String EndsCapital One · OACapital One interview questions
- Run-Length String CompressionSalesforce · OASalesforce interview questions
- Minimum Changes for Palindromic BlocksCitadel · OA · PHONE SCREEN · ONSITE INTERVIEWCitadel interview questions
- Count Binary SubstringsMicrosoft · OAMicrosoft interview questions
- Check a Repeated String as a SubsequenceQuince · OAQuince interview questions
- Reverse String In PlaceThe Walt Disney Company · OA · PHONE SCREENThe Walt Disney Company interview questions
- Lost MessagesSuperhuman · OASuperhuman interview questions
- Reverse a StringFlexTrade · OAFlexTrade interview questions
- Missing WordsVanguard · OAVanguard interview questions