I am confused when dealing with arithmetic around array indices, majorly around the corner cases.
For ex:
- Finding word in text ( search of needle in haystack). In following, it should be <= instead of <
public int search(char[] haystack, char[] needle) {
int hayStackTill = haystack.length - needle.length;
for(int i = 0; i < hayStackTill; i++) // it should be <= instead of <
}
- Given the size of array and count from last, Find the index from start
int index = a.length - countFromLast; // it should be instead a.length - countFromLast + 1
Can anyone help with some practice problems around this ( Also any suggestions are welcome).