Arpa's blog

By Arpa, history, 19 months ago, In English

I'm honored to introduce you to the article series, Arpa's problem of the month, hosted by Topcoder.

Every month, there will be a problem with complete explanations and solutions for one of the problems of the month. Here is the problem of April. Feel free to ask me questions and suggesting edits.

Help me by proposing a problem for the next month. In the May contests, look for a challenging problem that you would like to have complete explanations of it.

P. S. "Arpa's problem of April" is something rhythmic, isn't it?

 
 
 
 
  • Vote: I like it
  • +6
  • Vote: I do not like it

»
19 months ago, # |
  Vote: I like it -30 Vote: I do not like it

So you get paid for writing this article? Topcoder is a very nice company.

»
19 months ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

Is there a typo in code, as it is leading to an infinite loop for the first test case I tried: A = [1, 5, 7, 4, 5, 4, 1]

  • »
    »
    19 months ago, # ^ |
      Vote: I like it 0 Vote: I do not like it

    In fact never mind, looks like copy/pasting the code changed the indentation for this line which caused it :

                for i in range(curr_last):
                    if A[i] == curr_max:
                        A[i] -= 1
                #this line's indentation was not right when I copied, but looks right in the blog
                last_max = curr_max
    

    Very nice question/explanation indeed.