Whenever you find yourself writing a simple loop, you know that you have an O(n) algorithm. If that loop contains an inner loop, then you’re looking at O(m x n). You should be asking yourself how large these values can get.
The Pragmatic Programmer, From Journeyman to Master (Andrew Hunt, David Thomas)