Arrange Consonants and Vowels GFG POTD Python Solution geeks for geeks problem of the day

Опубликовано: 25 Октябрь 2024
на канале: VS Code
101
3

Problem - https://www.geeksforgeeks.org/problem...

Given a singly linked list having n nodes containing english alphabets ('a'-'z'). Rearrange the linked list in such a way that all the vowels come before the consonants while maintaining the order of their arrival.

Example 1:

Input:
n = 9
linked list: a - b - c - d - e - f - g - h - i
Output:
a - e - i - b - c - d - f - g - h
Explanation:
After rearranging the input linked list according to the condition the resultant linked list will be as shown in output.
Example 2:

Input:
n = 8
linked list: a - b - a - b - d - e - e - d
Output:
a - a - e - e - b - b - d - d
Explanation:
After rearranging the input linked list according to the condition the resultant linked list will be as shown in output