From d4289b1f0967baee325f7d27a7988882cd53f39d Mon Sep 17 00:00:00 2001 From: rimogsu Date: Thu, 24 Sep 2026 22:24:58 +0900 Subject: [PATCH] 1046 --- .../v3/1046. Last Stone Weight.py" | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 "leetcode3/\353\263\200\354\247\200\355\230\221/v3/1046. Last Stone Weight.py" diff --git "a/leetcode3/\353\263\200\354\247\200\355\230\221/v3/1046. Last Stone Weight.py" "b/leetcode3/\353\263\200\354\247\200\355\230\221/v3/1046. Last Stone Weight.py" new file mode 100644 index 00000000..e0e6f4de --- /dev/null +++ "b/leetcode3/\353\263\200\354\247\200\355\230\221/v3/1046. Last Stone Weight.py" @@ -0,0 +1,14 @@ +class Solution: + def lastStoneWeight(self, stones: list[int]) -> int: + stones.sort() + + while len(stones) >= 2: + s1 = stones.pop() + s2 = stones.pop() + + if s1 != s2: + stones.append(abs(s1 - s2)) + + stones.sort() + + return stones[0] if stones else 0 \ No newline at end of file