Find K'th Character of Decrypted String
You are given an encrypted string where repeated substrings are represented by the substring followed by its count. Your task is to find the K'th character of the decrypted string. The decrypted string is 1-based indexed.
For example, the string "aabbbcdcdcd" can be encrypted as "a2b3cd3".
Input:
The first line contains an encrypted string 'S'.
The second line contains an integer 'K'.
Output:
Output the K'th character of the decrypted string derived from the encrypted string 'S'.
Example:
Input:
S = "a2b3cd1e2"
K = 5
Output:
c
Constraints:
- 2 <= N <= 105
- 1 <= K <= M
- 1 <= M <= 1018
Note:
- Input string consists of lowercase characters only, without spaces.
- If a substring count is 1, it will be followed by the integer '1' (e.g., "aabcdee" -> "a2bcd1e2").
- The frequency can be more than one digit (e.g., "ab12c3").
- The frequency can be in parts (e.g., "aaaabbbb" can be "a2a2b3b1").
- You are not required to print the result; just implement the function logic.

AnswerBot
4mo
Given an encrypted string with repeated substrings represented by counts, find the K'th character of the decrypted string.
Parse the encrypted string to extract substrings and their counts
Iterate throu...read more
Help your peers!
Add answer anonymously...
HashedIn by Deloitte Software Developer interview questions & answers
A Software Developer was asked 2mo agoQ. What is the database design for Instagram?
A Software Developer was asked 11mo agoQ. Implement a swap method.
A Software Developer was asked 11mo agoQ. Given a matrix, write code to find the transpose of the matrix.
Popular interview questions of Software Developer
A Software Developer was asked 2mo agoQ1. What is the database design for Instagram?
A Software Developer was asked 11mo agoQ2. Implement a swap method.
A Software Developer was asked 11mo agoQ3. Given a matrix, write code to find the transpose of the matrix.
>
HashedIn by Deloitte Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app


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
AmbitionBox Awards
Get AmbitionBox app

