#3828
Final Element After Subarray Deletions
expert · 1020 · lc medium +32 · 40.1% accepted · 109 likes · top 19%
Description
Given an integer array nums, Alice and Bob alternate turns (Alice goes first). On each turn the active player picks any subarray nums[l..r] with length strictly less than the current array length m, removes it, and concatenates the rest. The game ends when a single element remains. Alice tries to maximize that element; Bob tries to minimize it. Assuming optimal play from both, return the final remaining element.
Code
1
2
3