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:

  1. If the character is a vowel, change it to the next character in the alphabetical sequence.
  2. If the character is a consonant, change it to the previous character in the alphabetical sequence.
  3. The next character of ‘z’ is ‘a’.
  4. 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
Select
Add answer anonymously...

Wipro Project Engineer interview questions & answers

A Project Engineer was asked 3d agoQ. Explain the logic behind determining if a number is prime.
A Project Engineer was asked 3w agoQ. Why have you not included C and C++ in your resume, considering you are a comput...read more
A Project Engineer was asked 1mo agoQ. Explain Interface with an example.

Popular interview questions of Project Engineer

A Project Engineer was asked 3d agoQ1. Explain the logic behind determining if a number is prime.
A Project Engineer was asked 3w agoQ2. Why have you not included C and C++ in your resume, considering you are a comput...read more
A Project Engineer was asked 1mo agoQ3. Explain Interface with an example.

Top HR questions asked in Wipro Project Engineer

A Project Engineer was asked 2mo agoQ1. What challenges did you face while working on the minor project?
A Project Engineer was asked 2mo agoQ2. Tell me about your final year project.
A Project Engineer was asked 2mo agoQ3. Would you prefer to work as a team leader or a team member?
Wipro Project Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
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

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits