FastPrepK-th Character in an Infinite String
Problems/K-th Character in an Infinite String

K-th Character in an Infinite String

Arcesium logoArcesium● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Arcesium full-time online assessment. Our version is about 99% the same as the reported question.

Build an infinite string from non-empty strings s and t in numbered blocks:

  1. Append s once.
  2. Append t twice.
  3. Append s three times.
  4. Append t four times.
  5. 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) → char

Examples

Example 1

s = "a"t = "bc"k = 4return = b

The beginning is abcbcaaabcbcbcbc.... Position 4 contains b.

Example 2

s = "ab"t = "x"k = 7return = a

The 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
All Arcesium interview questionsSee Arcesium hiring insights
Saved
class Solution {
    public char kthInfiniteCharacter(String s, String t, long k) {
      // Write your code here.
    }
}
Checking account…