Asked inMicrosoft Corporation,SWE Intern

Find K’th Character of Decrypted String

You are given an encrypted string where repetitions of substrings are expressed as the substring followed by the count of these substrings. The task is to find the 'K'th character in the decrypted string. The decrypted string uses 1-based indexing.

Example:
The string "aabbbcdcdcd" is encrypted as "a2b3cd3".

Input:

S: The encrypted string.
K: An integer representing the position in the decrypted string you need to find.

Output:

The character at the 'K'th position of the decrypted string obtained from string 'S'.

Example:

Input:
S = "a2b3cd3", K = 5
Output:
'b'

Constraints:

  • 2 <= N <= 105
  • 1 <= K <= M
  • 1 <= M <= 1018

Where 'N' is the length of the encrypted string 'S', and 'M' is the length of the decrypted string from 'S'. All characters in string 'S' are lowercase English letters.

Note: You only need to implement the function as output has been handled. Also, the string will not contain any spaces, and each substring is followed by an integer indicating its frequency.

Be the first one to answer
Select
Add answer anonymously...
Microsoft Corporation SWE Intern Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits