I am doing a code challenge where given two integers l and r, I have to print all the odd numbers between i and r (i and r inclusive). The function must return an array of integers denoting the odd numbers between l and r.
This is what I have so far
static List<Integer> oddNumbers(int l, int r) {
List<Integer> list1 = new ArrayList<>();
if ((r > l) && (l >= 1) && (r <= 100000)) {
for (int i = tmp; tmp < r; i++) {
if (l % 2 == 0)
l = l + 1;
list1.add(l);
l = l + 2;
}
}
return list1;
}
However, I received several errors like this
Compiler Message
Wrong Answer
Your Output (stdout)
Output hidden
Any ideas for this? on the QA of the challenge site, it seems related to Corner case problems.