Given N bulbs, either on(1) or off(0).
Turning on i’th bulb causes all remaining bulbs on the right to flip,
Find the minimum number of switches to turn all the bulbs on
Solution:
Bits
0 | 1 | 0 | 1 | 0 | 1 | 1 |
---|---|---|---|---|---|---|
1 | 0 | 1 | 0 | 1 | 0 | 0 |
1 | 1 | 0 | 1 | 0 | 1 | 1 |
1 | 1 | 1 | 0 | 0 | 0 | 0 |
1 | 1 | 1 | 1 | 1 | 1 | 1 |
Cost
0 |
---|
1 |
2 |
3 |
4 |
Highest Product
Given an array, find the highest product possible.
Disjoint interval
Given a list of intervals: [start, end]
Find the length of the maximal set of mutually disjoint intervals.
Largest Permutation
Given an array A of a random permutation of numbers from 1 to N. Given B is the number of swaps permitted in A, find the largest permitation possible
Meeting Rooms
Given a list of intervals: [s,e] for meetings, find the least number of meeting rooms required.