When I run the program, it works and all requierements are met, but when I validate it, it says that it's not good. Please help me. Thanks!
package fr.codegym.task.task07.task0716;
import java.util.ArrayList;
/*
R ou L
*/
public class Solution {
public static void main(String[] args) throws Exception {
ArrayList<String> liste = new ArrayList<>();
liste.add("rose"); // 0
liste.add("love"); // 1
liste.add("lyre"); // 2
liste = corriger(liste);
for (String s : liste) {
System.out.println(s);
}
}
public static ArrayList<String> corriger(ArrayList<String> liste) {
// écris ton code ici
for (int i=0;i< liste.size();i++){
boolean r= false;
boolean l = false;
String s= liste.get(i);
for (int j= 0; j<s.length(); j++){
if (s.charAt(j)=='r') r=true;
if (s.charAt(j)== 'l') l=true;
}
if (l && r) break;
if (r) {
liste.remove(i);
i--;
}
if(l) {
liste.add(i, liste.get(i));
i++;
}
}
return liste;
}
}