Encoding a word into Pig Latin
Last Updated :
22 Jul, 2022
Design a program to take a word as an input, and then encode it into Pig Latin. A Pig Latin is an encrypted word in English, which is generated by doing the following alterations:
The first vowel occurring in the input word is placed at the start of the new word along with the remaining alphabet of it. The alphabet is present before the first vowel is shifted, at the end of the new word it is followed by “ay”.
Examples:
Input: s = "paris"
Output: arispay
Input: s = "amazon"
Output: amazonay
- Find index of first vowel.
- Create pig latin by appending following three.
- Substring after starting with the first vowel ……..till end.
- Substring before first vowel.
- “ay”.
Implementation:
CPP
Java
Python3
C#
Javascript
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...