There is a given number of stairs
n. Stairs can be either taken two steps at a time or one step at a time. For a height of
1, there is only one possible solution:
1. For a height of
2, there are two solutions:
The task is to find out of a series of stock prices the best time to buy and sell the stock. Only one stock can be owned at the time and it can be sold and bought at the same time.
The task is to find out if a given string is comprised of multiple identical substrings. The first observation is that the substring cannot be longer than half of the length of the original string. The second observation is that the length of the total string has to be a multiple of the string that is tested, if it is not it can be discarded right away. Lastly, a string with the length of one can be discarded immediately.
A classic find the
needle in the
haystack problem. The task is to find if a string is contained within another string and return the index of the first position. If the string is not contained return
-1 and if the
needle is empty, return