We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8fc1dd4 commit f541aa1Copy full SHA for f541aa1
missing-number/gyeo-ri.py
@@ -8,10 +8,17 @@
8
9
class Solution:
10
def missingNumber(self, nums: list[int]) -> int:
11
+ # (Runtime: 3ms / Beats 61.16%, Memory 20.23MB / Beats: 98.53% )
12
len_nums = len(nums)
13
total_sum = int(len_nums * (len_nums + 1) / 2)
14
return total_sum - sum(nums)
15
16
+ """
17
+ 이때, 아래와 같이 변수 선언 없이 계산하면(In Memory) 메모리는 조금 더 쓰지만 속도는 빨라진다.
18
+ (Runtime: 0ms / Beats 100.00%, Memory 20.34MB / Beats: 90.41% )
19
+ return int(len(nums) * (len(nums) + 1) / 2) - sum(nums)
20
21
+
22
23
if __name__ == "__main__":
24
test_cases = [
0 commit comments