Game on Permutation
Alice and Bob play a game on a permutation p of size n, where every integer from 1 to n appears exactly once. They also have a chip that can be placed on any element.
Alice moves first: she chooses any element and places the chip on it. After that the players alternate, Bob moving second. On every later move, the player whose turn it is must move the chip from its current position i to a position j such that j < i and p[j] < p[i]. In other words, the chip must move to an element that is simultaneously to the left of the current element and strictly smaller than it.
If a player cannot make a move, that player wins the game immediately.
An element at index i is called lucky if Alice can win by placing the chip there on her first move, no matter how Bob plays. Return the number of lucky elements in the permutation.
Game on Permutation
Alice and Bob play a game on a permutation `p` of size `n`, where every integer from `1` to `n` appears exactly once. They also have a chip that can be placed on any element.