
Encode The String Problem Statement
Given a string S
of length N
, encode it using the specified rules related to vowels and consonants.
Explanation:
Follow these encoding rules:
- If the character is a vowel, change it to the next character in the alphabetical sequence.
- If the character is a consonant, change it to the previous character in the alphabetical sequence.
- The next character of ‘
z
’ is ‘a
’. - The previous character of ‘
a
’ is ‘z
’.
Input:
The first line contains an integer 'T', which denotes the number of test cases. Each test case consists of:
The first line with integer ‘N’, the length of the string.
The second line contains a string ‘S’ of length ‘N’.
Output:
The encoded string for each test case on a new line.
Example:
Suppose:
N = 4, S = "code"
Following the encoding rules, the encoded string becomes "bpcf".
Constraints:
- 1 <= T <= 10
- 1 <= N <= 10^5
- The sum of all 'N' in all test cases <= 10^5
- The string 'S' contains only lowercase letters.
Note:
You don’t need to handle the output; just implement the function to return the required encoded string.

AnswerBot
4d

Encode a given string based on specified rules related to vowels and consonants.
Iterate through each character in the string and apply the encoding rules based on whether it is a vowel or consonant.
Ha...read more
Satyam Kashyap
1mo

N=4,S code
Following the encoding rules, the encoded string become "bpcf''
Anonymous
11mo

Encode The String You are given a password string P of length N. The password needs to be encoded before storing it to the database. The password string can be encoded using the following rules: 1) If...read more
Add answer anonymously...
Top Wipro Project Engineer interview questions & answers
Popular interview questions of Project Engineer
Top HR questions asked in Wipro Project Engineer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app