hardSimulationString 0 views

Process String with Special Operations II

You are given a string s consisting of lowercase English letters and the special characters: '*', '#', and '%'.

You are given a string s consisting of lowercase English letters and the special characters: '*', '#', and '%'.

You are also given an integer k.

Build a new string result by processing s according to the following rules from left to right:

Return the kth character of the final string result. If k is out of the bounds of result, return '.'.

Process String with Special Operations II diagram

Example 1

Input: s = "a#b%*", k = 1

Output: "a"

Explanation: The final result is "ba" . The character at index k = 1 is 'a' .

Example 2

Input: s = "cd%#*#", k = 3

Output: "d"

Explanation: The final result is "dcddcd" . The character at index k = 3 is 'd' .

Example 3

Input: s = "z*#", k = 0

Output: "."

Explanation: The final result is "" . Since index k = 0 is out of bounds, the output is '.' .

Constraints

  • 1 <= s.length <= 10^5
  • s consists of only lowercase English letters and special characters '*', '#', and '%'.
  • 0 <= k <= 1015
  • The length of result after processing s will not exceed 1015.

Hints

Companies

No companies reported yet.

Discussion

Sign in to join the discussion.

Loading discussion...

Test results

No test cases yet.