Tip 1 : Be consistent
Tip 2 : Be dedicated
Tip 3 : Concepts should be crystal clear.
Tip 1 : Make projects
Tip 2 : Write only what you know.
We cannot use the element at a given index twice.
Try to do this problem in O(N) time complexity.
1. The grid has 0-based indexing.
2. A rotten orange can affect the adjacent oranges 4 directionally i.e. Up, Down, Left, Right.
If we are given an array ARR=[1,2,3] then the power set P(ARR) of the set ARR is: [ [], [1], [2], [1,2], [3], [1,3], [2,3], [1,2,3] ]
For every subset 'X' present in power set P(ARR) of set ARR, X must be sorted i.e. in the example above:
P1(ARR) = [ [], [1], [2], [1,2], [3], [1,3], [2,3], [1,2,3] ]
P2(ARR) = [ [], [1], [1,2,3], [2], [1,2], [3], [1,3], [2,3] ]
P3(ARR) = [ [], [1], [2], [1,2], [3], [1,3], [2,3], [2,3,1] ]
P1(ARR) and P2(ARR) will be considered correct power sets but P3(ARR) will not be considered correct because there the last subset [2, 3, 1] is not sorted.
Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
Which operator is used for exponentiation in Python?