04pallav
9/11/2017 - 10:22 PM

Universal DS Notes

Universal DS Notes

##################
When you are moving the pointer once check for ptr.next
while ptr.next:
  ptr=ptr.next
When you are moving the pointer twice check for ptr and ptr.next
while ptr and ptr.next:
  ptr=ptr.next.next
  
##################
Power in python is ** and NOT ^

################################

string to list  ::::::: list(str)
list to string  ::::::: ''.join(ls)
###############################
###################################good way to check for ANY condition 
i=0
while i<len(range(list):
    if i!=2:      ###### Returning false if any i is 2
        return False
    i+=1
return True       ###### else return true
##################################################
LIST COMPREHENSION IN PYTHON IF ELSE 
[x-1 if x>0 else 0 for x in list]
###################################################
Checking if all elements are zero in list
all(x==0 for x in list)
##################################################