Given a string str, the task is to print the pattern given in the examples below:
Input: str = “geeks”
Reverse of “geeks” is “skeeg”
Replace first and last character with ‘*’ i.e. *kee*
Replace second and second last character in the modified string i.e. **e**
And so on.
Input: str = “first”
- Print the unmodified string.
- Reverse the string and initialize i = 0 and j = n – 1.
- Replace s[i] = ‘*’ and s[j] = ‘*’ and update i = i + 1 and j = j – 1 then print the modified string.
- Repeat the above steps while j – i > 1.
Below is the implementation of the above approach:
geeks *kee* **e**
Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.
- First substring whose reverse is a word in the string
- Program to print reverse character bridge pattern
- Length of the largest substring which have character with frequency greater than or equal to half of the substring
- Find if a given string can be represented from a substring by iterating the substring “n” times
- Minimum length of substring whose rotation generates a palindromic substring
- Partition given string in such manner that i'th substring is sum of (i-1)'th and (i-2)'th substring
- Substring Sort
- DFA that begins with 'a' but does not contain substring 'aab'
- Longest substring of vowels
- Longest Common Substring | DP-29
- Shortest Palindromic Substring
- Check if a string is substring of another
- Palindrome Substring Queries
- Frequency of a substring in a string
- Largest substring with same Characters
- Longest Palindromic Substring | Set 2
- Longest Palindromic Substring | Set 1
- Longest Non-palindromic substring
- Longest substring with count of 1s more than 0s
- Length of the longest substring that do not contain any palindrome
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. 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.