package com.codegym.task.task07.task0716;
import java.util.ArrayList;
/*
R or L
*/
public class Solution {
public static void main(String[] args) throws Exception {
ArrayList<String> list = new ArrayList<String>();
list.add("rose"); // 0
list.add("love"); // 1
list.add("lyre"); // 2
list = fix(list);
for (String s : list) {
System.out.println(s);
}
}
public static ArrayList<String> fix(ArrayList<String> list) {
for (int i = 0; i < list.size(); i++) {
boolean hasR = false;
boolean hasL = false;
for (int j = 0; j < list.get(i).length(); j++) {
if (list.get(i).charAt(j) == 'r') {
hasR = true;
}
if (list.get(i).charAt(j) == 'l') {
hasL = true;
}
}
if (hasR == true && hasL == false) {
list.remove(i);
}
else if(hasR == false && hasL == true) {
list.add(list.get(i));
}
else {
//do nothing
}
}
return list;
}
}