Given an integer N, the task is to find the N-th character in the string made by concatenating natural numbers (Integers beginning from 1). The starting sting will be “12345678910111213..”.
Input: N = 3 Output: 3 3rd character in the string "12345678910111213.." is 3. Input: N = 11 Output: 0 11th character in the string "12345678910111213..." is 0
The idea is to generate the required string until string length does exceeds N.
- Initialize a Null string and c=1
- Add the c to the string by type-casting it to a character
- If c is a single digit number, append it to the string
- if c is greater than 9, then store it in a temporary string and reverse it and append to the original string
- If at any moment the string length exceeds N, then return s[n-1].
Below is the implementation of the above approach:
- Find the starting indices of the substrings in string (S) which is made by concatenating all words from a list(L)
- Pairs of strings which on concatenating contains each character of "string"
- Check if a two character string can be made using given words
- Find the character made by adding all the characters of the given string
- Check whether a binary string can be formed by concatenating given N numbers sequentially
- Check if two strings can be made equal by swapping one character among each other
- Check whether given string can be generated after concatenating given strings
- Lexicographically smallest string obtained after concatenating array
- Longest Palindrome in a String formed by concatenating its prefix and suffix
- Replace every character of string by character whose ASCII value is K times more than it
- Modify the string such that every character gets replaced with the next character in the keyboard
- Find a string such that every character is lexicographically greater than its immediate next character
- Check if frequency of character in one string is a factor or multiple of frequency of same character in other string
- Map every character of one string to another such that all occurrences are mapped to the same character
- Find position of the given number among the numbers made of 4 and 7
- Replace every character of a string by a different character
- Find two numbers made up of a given digit such that their difference is divisible by N
- Check whether the string S1 can be made equal to S2 with the given operation
- Check if a string is made up of K alternating characters
- Check if a given string is made up of two alternating characters
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.