From 9ed84e35cf8574078710fefcd95de31675f4ee52 Mon Sep 17 00:00:00 2001 From: Vombit <45901675+Vombit@users.noreply.github.com> Date: Thu, 28 May 2026 12:06:43 +0500 Subject: [PATCH] 7 --- solutions/lc2154.py | 8 ++++++++ solutions/lc747.py | 5 +++++ 2 files changed, 13 insertions(+) create mode 100644 solutions/lc2154.py create mode 100644 solutions/lc747.py diff --git a/solutions/lc2154.py b/solutions/lc2154.py new file mode 100644 index 0000000..9a16735 --- /dev/null +++ b/solutions/lc2154.py @@ -0,0 +1,8 @@ +class Solution: + def findFinalValue(self, nums: List[int], original: int) -> int: + nums_s = set(nums) + + while original in nums_s: + original *= 2 + + return original diff --git a/solutions/lc747.py b/solutions/lc747.py new file mode 100644 index 0000000..097513c --- /dev/null +++ b/solutions/lc747.py @@ -0,0 +1,5 @@ +class Solution: + def dominantIndex(self, nums: List[int]) -> int: + nums_s = sorted(nums) + + return nums.index(nums_s[-1]) if nums_s[-1] >= nums_s[-2] * 2 else -1