What is the smallest integer greater than 95555 in which there will be 4 identical numbers?
Ans: 96666? nope, its 95999 :-)
Ans: 96666? nope, its 95999 :-)
If I have eight hours for cutting wood, I spend six sharpening my axe.

O(1).print "hello";
O(1).print "hello";
print "hello";
print "hello";
i goes from 1 to 2 to 4 to 8 to 16 to 32 ...for(int i = 1; i <= n; i = i * 2)
print "hello";
i goes from 1 to 3 to 9 to 27...for(int i = 1; i <= n; i = i * 3)
print "hello";
for(double i = 1; i < n; i = i * 1.02)
print "hello";
for(int i = 0; i < n; i++)
print "hello";
for(int i = 0; i < n; i = i + 2)
print "hello";
O(log(n)) and O(n). The nesting of the for loops help us obtain the O(n*log(n))for(int i = 0; i < n; i++)
for(int j = 1; j < n; j = j * 2)
print "hello";
O(n*log(n))for(int i = 0; i < n; i = i + 2)
for(int j = 1; j < n; j = j * 3)
print "hello";
O(n^2) is obtained easily by nesting standard for loops.for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
print "hello";
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j = j + 2)
print "hello";
for(int i = 0; i < n; i++)
for(int j = 0; j < n; j++)
for(int k = 0; k < n; k++)
print "hello";
O(n^3).for(int i = 0; i < n; i++)
for(int j = 0; j < n + 5; j = j + 2)
for(int k = 0; k < n; k = k + 3)
print "hello";
O(log N) basically means time goes up linearly while the n goes up exponentially. So if it takes 1second to compute 10 elements, it will take 2 seconds to compute 100 elements, 3 seconds to compute 1000 elements, and so on.O(log n) when we do divide and conquer type of algorithms e.g binary search. Another example is quick sort where each time we divide the array into two parts and each time it takes O(N) time to find a pivot element. Hence it N O(log N)