3 thoughts on “Udacity – Intro to Computer Science – Python – Flag High Watermark From List”

  1. It’s a really brilliant solution! Except, I don’t think the first solution is a hundred percent correct. I mean, according to the code, the maxnum will be replace only if the num is bigger than the maxnum. In that case when the input is 6352, it will get the result [6,[3,5,2]], which is not correct. Correct me if I’m wrong but I think the line <maxNum=num should be written under the else line.

  2. Got it after a long time!

    def numbers_in_lists(string):
    list=[]
    n=len(string)
    i=0
    previous=0
    while iprevious:
    list.append(int(string[i]))
    previous = string[i]
    i=i+1
    while i<n and string[i]<=previous:
    placeholder.append(int(string[i]))
    i=i+1
    if placeholder != []:
    list.append(placeholder)
    return list

Comments are closed.