
Asked in Wipro
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
4mo
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
5mo
N=4,S code
Following the encoding rules, the encoded string become "bpcf''
Anonymous
1y
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 Project Engineer Interview Questions Asked at Wipro
Q. Explain the logic behind determining if a number is prime.
Q. What is the need for using Salesforce?
Q. Why have you not included C and C++ in your resume, considering you are a comput...read more
Interview Questions Asked to Project Engineer at Other Companies
Top Skill-Based Questions for Wipro Project Engineer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Networking Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
C++ Interview Questions and Answers
150 Questions
Stay ahead in your career. Get AmbitionBox app


Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+
Reviews
10L+
Interviews
4 Cr+
Salaries
1.5 Cr+
Users
Contribute to help millions
AmbitionBox Awards
Get AmbitionBox app

