Simplest solution for this algorithm


  • 0
    W

    L=list(input('enter the numbers:'))
    S=False
    if L[0]>1 and L[1]==L[0]+1 :
    print (L[0]-1)
    else :
    i=0
    while i<len(L) and S==False :
    while i<len(L)-1 and L[i+1]==L[i]+1 :
    i+=1
    if L[i]+1>0 :
    S=True
    if S==False :
    i+=1
    if S :
    print (L[i]+1)
    else :
    print ("this number does not exist ")


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.