Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions Perm_Missing.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ def solution(inp: list):
# to get the expect sum, since it is supposed to be consecutive,
# we can use method like x*(x+1)/2, Gaussian way
expected_sum = (num + 1) * (min_number + max_number) / 2
missing = int(expected_sum - actual_sum)
return int(expected_sum - actual_sum)
else:
missing = None

return missing
return None
Comment on lines -16 to +18
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function solution refactored with the following changes:


if __name__ == '__main__':
print(solution([2, 3, 1, 5]))
Expand Down