K-th Character in an Infinite String
Updated
Problem statement
Build an infinite string from non-empty strings s and t in numbered blocks:
- Append
sonce. - Append
ttwice. - Append
sthree times. - Append
tfour times. - Continue alternating strings while increasing the repetition count by one for each block.
Given a 1-indexed position k, return the character at that position.
Function
kthInfiniteCharacter(s: String, t: String, k: long) → charExamples
Example 1
s = "a"t = "bc"k = 4return = bThe beginning is abcbcaaabcbcbcbc.... Position 4 contains b.
Example 2
s = "ab"t = "x"k = 7return = aThe first three blocks are ab, xx, and ababab. Position 7 is the third character of the third block, which is a.
Constraints
1 <= s.length, t.length <= 100.1 <= k <= 10^16.
More Arcesium Online Assessment questions
- City Infection NumberOA · Seen Jul 2025
- Minimum Tunnel Crossing TimeOA · Seen Jul 2025
- Product of Subset MaximaOA · Seen Jul 2025
- Reconstruct the Root StreamOA · Seen Jul 2025
- Add DigitsOA · Seen Aug 2023
- Binary Tree Maximum Path SumOA · Seen Aug 2023
- Detect a Cycle in Directed Hate RelationshipsOA · Seen Aug 2023
- Reverse First K Characters in Every 2K BlockOA · Seen Aug 2023
- Robo Data Sharing DirectionOA · Seen Jul 2023
- Capital Gains Tax from TradesOA · Seen Feb 2021
Similar questions at other companies
- Perfect Squares Matching a PatternNielsen · OA
- Server Upgrade PlanningWells Fargo · OAWells Fargo interview questions
- Count Proper Prefix MatchesAT&T · OAAT&T interview questions
- Simplify a Quadratic ExpressionOpenAI · OAOpenAI interview questions
- Maximum Alloy Production Within BudgetMicrosoft · OAMicrosoft interview questions
- Next Number with Disjoint DigitsElevenLabs · OAElevenLabs interview questions
- Linear InterpolatorTwo Sigma · OATwo Sigma interview questions
- Vowel Substring GameAkuna Capital · OAAkuna Capital interview questions
- Minimum Anagram PeriodVisa · OAVisa interview questions
- Return Exact Cash Register ChangeBank of America · OA