Given a string s, create a new string such that it contains the characters of the two halves of the string s combined alternately in reverse order.
Input : s = carbohydrates Output : hsoebtraarcdy Input : s = sunshine Output : sennuish
Example 1: Two halves of the string carbohydrate are carboh and ydrates. As they needed to be added in reverse alternately, start with h from first half then s from second half followed by o from first half, e from second half and so on. The string p comes out to be hsoebtraarcdy. If one of the string is completely finished then simply add the remaining characters of the other string in reverse order.
Example 2: The two halves of the string are suns and hine. String sennuish is the desired string p.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Count ways to place all the characters of two given strings alternately
- Check if both halves of the string have same set of characters
- Check if both halves of the string have same set of characters in Python
- Check if both halves of the string have at least one different character
- Check if both halves of a string are Palindrome or not
- Interchanging first and second halves of stings
- Rearrange the characters of the string such that no two adjacent characters are consecutive English alphabets
- Reverse a string without affecting special characters
- Reverse alternate k characters in a string
- Reverse Middle X Characters
- Min flips of continuous characters to make all characters same in a string
- String with k distinct characters and no same characters adjacent
- Permutation of a string with maximum number of characters greater than its adjacent characters
- Count of ungrouped characters after dividing a string into K groups of distinct characters
- Minimum cost to remove the spaces between characters of a String by rearranging the characters
- Find Kth largest string from the permutations of the string with two characters
- Change string to a new character set
- Replace minimal number of characters to make all characters pair wise distinct
- Minimum number of operations to move all uppercase characters before all lower case characters
- Minimum characters that are to be inserted such that no three consecutive characters are same
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.