I am unable to understand this runtime error since I am only trying to insert 1 element in the list... java.lang.OutOfMemoryError: Solution.java, method fix, line: 35 But if I just change the order of input, the error vanishes...
list.add("rose"); // 0
list.add("love"); // 1
list.add("lyre"); // 2
But the output is something like
love
lyre
Insted of...
love
love
lyre
And I am unable to find the problem with
else if ((list.get(i)).contains("l")) {
           list.add(i, list.get(i));
}
Help would be appreciated...Thank You!