We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
原代码: def max(arr): if len(arr) == 2: return arr[0] if arr[0]>arr[1] else arr[1] else: sub_max = max(arr[1:]) return arr[0] if arr[0]>sub_max else sub_max
修改后: def max(arr): if len(arr) == 1: return arr[0] elif len(arr) == 2: return arr[0] if arr[0]>arr[1] else arr[1] else: sub_max = max(arr[1:]) return arr[0] if arr[0]>sub_max else sub_max
The text was updated successfully, but these errors were encountered:
书上的更易于理解哦
Sorry, something went wrong.
No branches or pull requests
原代码:
def max(arr):
if len(arr) == 2:
return arr[0] if arr[0]>arr[1] else arr[1]
else:
sub_max = max(arr[1:])
return arr[0] if arr[0]>sub_max else sub_max
修改后:
def max(arr):
if len(arr) == 1:
return arr[0]
elif len(arr) == 2:
return arr[0] if arr[0]>arr[1] else arr[1]
else:
sub_max = max(arr[1:])
return arr[0] if arr[0]>sub_max else sub_max
The text was updated successfully, but these errors were encountered: