Skip to content

Instantly share code, notes, and snippets.

@Dbhardwaj99
Last active January 11, 2022 20:21
Show Gist options
  • Save Dbhardwaj99/4992268bd13ff759fa25b5fa7e6877ba to your computer and use it in GitHub Desktop.
Save Dbhardwaj99/4992268bd13ff759fa25b5fa7e6877ba to your computer and use it in GitHub Desktop.
def sumNdifference(array):
j = 1
array = sorted(array)
array = array[::-1]
while (true)):
diff = array[len(array)-1]
other = sum(array[j:])
if array[0]-other > 0:
diff = array[0]-other
break
else:
j = j+1
answer = [sum(array), diff]
return answer
@rubykar
Copy link

rubykar commented Jan 11, 2022

Looks dope,well thought out code,great use of functions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment