aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorterminaldweller <devi@terminaldweller.com>2023-12-05 03:17:13 +0000
committerterminaldweller <devi@terminaldweller.com>2023-12-05 03:17:13 +0000
commitd776ffc55f83ac2ec0c06d6ed89c1c2d3f3cd3e0 (patch)
tree9b1f95a56c737fcf44a70f796fb3891fa4cb692d
parent2264 (diff)
downloadleetcode-d776ffc55f83ac2ec0c06d6ed89c1c2d3f3cd3e0.tar.gz
leetcode-d776ffc55f83ac2ec0c06d6ed89c1c2d3f3cd3e0.zip
1688
-rwxr-xr-x1688/main.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/1688/main.py b/1688/main.py
new file mode 100755
index 0000000..531f7f1
--- /dev/null
+++ b/1688/main.py
@@ -0,0 +1,20 @@
+#!/usr/bin/env python
+
+class Solution:
+ def numberOfMatches(self, n: int) -> int:
+ matches = 0
+ while n > 1:
+ if n % 2 == 0:
+ matches += n // 2
+ n = n // 2
+ else:
+ matches += (n - 1) // 2
+ n = (n - 1) // 2 + 1
+ return matches
+
+def main():
+ solution = Solution()
+ print(solution.numberOfMatches(7))
+
+if __name__ == "__main__":
+ main()