# R or L

• 10
• Locked
Our friends from Planet Chi-Knees have an unusual problem: they have a really hard time distinguishing between the letters "r" and "l". We decided to help them with this task. The experimental fix method will remove from a string list all words containing the letter "r", and it will duplicate all words containing the letter "l".
You can't complete this task, because you're not signed in.
sgubow
Level 10, Forest Grove, United States
28 April, 17:09
Here is a great link to help you understand how to search characters in a string, helped me out a ton: https://www.geeksforgeeks.org/searching-for-character-and-substring-in-a-string/ I'm sure you can compile a satisfactory solution after reading & understanding character functions.
ImDevin
Level 9, Old Town, United States
21 April, 03:32
the most difficult/important part of the solution is using extra i++ and i-- once. Took a while to understand why these were necessary, but it's important b/c the logic fails without them, never mind the checker.
Jurij Thmsn
Level 22, Flensburg, Germany
13 January, 10:22
Hardest exercise so far. I spent 6 hours on this and had to get help to be able to resolve it. Still don't really understand why. Feels disappointing.
Joe M
Level 11, East Coast, United States
22 November 2020, 02:23
Oh man this is tough to understand....I downloaded solution :(. Thanks to all who triedit. I looked at your tries and learned something.
MIHAI
Level 9, Timisoara, Romania
18 November 2020, 10:19
I think there is a problem of explanation of this exercise, should be rectified from the admin ... how can be the point 2.1 before 2.3??? if you remove all the words with containing "r" at the point 2.1 how does the point 2.3 be fulfilled??? so the paragraph 2.3 should be 2.1 :) ....
ъуъ
Level 9, Vilnius, Lithuania
7 October 2020, 13:56
A hint how I did it: 1. For a fix method use "for loop" (int i = 0; i < list.size();) to iterate through the list, but don't specify the 3rd argument (i++). 2. Inside the loop use 3 if / else if statements: 2.1. if ((string contains "r" AND "l") OR (doesn't contain "r" AND "l) proceed iteration (i++); 2.2. else if a string contains "r" use .remove but don't iterate further (leave i unchanged); 2.3. else if a string contains "l" use .add to duplicate the string, but make sure to place at exact index iteration is at ( .add(i, list.get(i)) ). Iterate further 2 steps (i+= 2); 3. And lastly don't forget to change return statement so it returns the list, not null. I hope it helps. Good Luck!
Maria
Level 18, Moscow, Russian Federation
5 November 2020, 10:26
thank you a lot!!!
ziv fisher
Level 9, Petah Tikva, israel
2 October 2020, 19:41
A hint for the ones who choses to use a new ArrayList<String>. In the end, right before the "return" statement use: Collections.reverse(yourNewArrayList); // To rearrange yourNewArrayList backwards.
monipuff
Level 14, United Kingdom
11 August 2020, 13:22
Managed to complete the task by creating and returning inner list within a method.
Rebekah H
Level 8, Gothenburg, Sweden
4 August 2020, 09:11
hint: the function should not return null.
Eefke Burg
Level 8, Utrecht, Netherlands
1 November 2020, 11:08
Thanks!
Petros
Level 23, Columbia, United States
22 July 2020, 03:12
Solved it but kind of brutal trying to see what works.