How to find a single words in a String ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

How to find a single words in a String ?

Like as Input :- rarad Output :- d Input raraddmk Output mk

23rd Aug 2019, 3:49 PM
GOPAL Patidar
GOPAL Patidar - avatar
2 Answers
+ 5
you can make a loop for each letter index in input, and inside it another loop for iterating over each letter of input(except index of character outer loop) if same character found then break; else when reach last index in inner loop just print that character
23rd Aug 2019, 4:10 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 1
1. Turn the string into an array. 2. Iterate through the character array and find the characters you need. 3. If it's a single character (like your 1st example), print them directly. Concat multiple characters (like your 2nd example) using +""+ when printing.
23rd Aug 2019, 4:06 PM
Tashila Pathum
Tashila Pathum - avatar