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
Charan Singh
1y
function findKthElement(encryptedStr , k){ let decryptedStr = '' let i = 0 //Decrypting the String while(i < encryptedStr.length){ let currentChar = '' let count= '' while(i < encryptedStr.length && i...read more
Help your peers!
Add answer anonymously...
Deloitte Software Developer interview questions & answers
A Software Developer was asked 6mo agoQ. What is MVC and explain its pattern?
A Software Developer was asked 7mo agoQ. Given a string, determine whether it is a palindrome, considering only alphanume...read more
A Software Developer was asked 7mo agoQ. Given two strings s and t, return true if t is an anagram of s, and false otherw...read more
Popular interview questions of Software Developer
A Software Developer was asked 6mo agoQ1. What is MVC and explain its pattern?
A Software Developer was asked 7mo agoQ2. Given a string, determine whether it is a palindrome, considering only alphanume...read more
A Software Developer was asked 7mo agoQ3. Given two strings s and t, return true if t is an anagram of s, and false otherw...read more
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

