Leetcode Problem 1686. Stone Game VI

1686. Stone Game VI

Leetcode Solutions

Sort by Value Sum

  1. Create a list of tuples where each tuple contains the value of the stone for Alice, the value for Bob, and the sum of both values.
  2. Sort the list of tuples in descending order based on the sum of values.
  3. Initialize two variables to keep track of Alice's and Bob's scores.
  4. Iterate over the sorted list, with Alice picking the stone at even indices and Bob picking at odd indices.
  5. Update Alice's and Bob's scores based on their respective values for the chosen stones.
  6. After all stones have been picked, compare Alice's and Bob's scores to determine the winner.
UML Thumbnail

Greedy Approach with Priority Queue

Ask Question

Programming Language
image/screenshot of info(optional)
Full Screen
Loading...

Suggested Answer

Answer
Full Screen
Copy Answer Code
Loading...