Skip to content

Commit 43530a1

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 5650e7d commit 43530a1

3 files changed

Lines changed: 7 additions & 1 deletion

File tree

data_structures/arrays/majority_element.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Find the majority element in an array.
33
"""
44

5+
56
def majority_element(nums: list[int]) -> int:
67
"""
78
Find the element that appears more than n/2 times using
@@ -25,11 +26,12 @@ def majority_element(nums: list[int]) -> int:
2526
for num in nums:
2627
if count == 0:
2728
candidate = num
28-
count += (1 if num == candidate else -1)
29+
count += 1 if num == candidate else -1
2930

3031
return candidate
3132

3233

3334
if __name__ == "__main__":
3435
import doctest
36+
3537
doctest.testmod()

data_structures/arrays/maximum_subarray.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Find the maximum subarray sum (Kadane's Algorithm).
33
"""
44

5+
56
def max_subarray(nums: list[int]) -> int:
67
"""
78
Find the contiguous subarray with the largest sum.
@@ -31,4 +32,5 @@ def max_subarray(nums: list[int]) -> int:
3132

3233
if __name__ == "__main__":
3334
import doctest
35+
3436
doctest.testmod()

data_structures/arrays/rotate_array.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Rotate an array to the right by k steps.
33
"""
44

5+
56
def rotate(nums: list[int], k: int) -> list[int]:
67
"""
78
Rotate the array to the right by k steps.
@@ -28,4 +29,5 @@ def rotate(nums: list[int], k: int) -> list[int]:
2829

2930
if __name__ == "__main__":
3031
import doctest
32+
3133
doctest.testmod()

0 commit comments

Comments
 (0)