Within a rectangular area (a matrix M * M elements) I access several parts of it (each N * N, but N varies). Some of these parts might overlap and i don't want to access those parts (elements) a second time.

I know there must be an algorithm to combine the parts I accessed already and tell me what parts do overlap if I want to access 'another region', but I can't find it.
best for me would be a c# program, but an algorithm would be OK as well