Most code you write is loops, so most complexity questions come down to counting how often the innermost line runs. A loop inside a loop over the same array is usually O(n²), while a loop that halves i each step is O(log n). Use this to check your own solution and to spot the nested loop that will time out. Be careful with two loops one after another: they add up to O(n + m), they do not multiply.