We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Loading...
  • Practice
  • Compete
  • Jobs
  • Leaderboard
  1. Practice
  2. Python
  3. Basic Data Types
  4. Find the Runner-Up Score!
  5. Discussions

Find the Runner-Up Score!

  • Problem
  • Submissions
  • Leaderboard
  • Discussions
  • Editorial

    You are viewing a single comment's thread. Return to all comments →

  • hyankov 3 years ago+ 2 comments

    Oops, my bad - I missed you were using set prior sorting. Nevermind - it looks great!

    4|
    ParentPermalink
    • santosheswaran 3 years ago+ 5 comments

      5

      -7 -7 -7 -7 -6

      for this input i think your code wont wholes good

      -1|
      ParentPermalink
      • albert18 3 years ago+ 3 comments

        This code doesn't work for test case 5 -7 -7 -7 -7 -6 because his while he takes the input as lis the elements in it are strings not integers so you've to convert those elements into integers and then run the code.

        N= input() L= raw_input().split() I=[] assert N>=2 and N<=10 for i in L: I.append(int(i)) I.sort() largest=max(I) count=I.count(largest) for i in range(count): I.remove(largest) print max(I)

        0|
        ParentPermalink
        • tcloaa 2 years ago+ 0 comments

          His code works. You should try it again dude

          2|
          ParentPermalink
        • nick3499 1 year ago+ 0 comments
          [deleted]
          1|
          ParentPermalink
        • achintya0210 5 months ago+ 0 comments

          Works in python 2 only

          0|
          ParentPermalink
      • 23editorcs 3 years ago+ 0 comments
        [deleted]
        -1|
        ParentPermalink
      • 23editorcs 3 years ago+ 1 comment

        It still works. I just checked.

        0|
        ParentPermalink
        • KeyurPotdar 2 years ago+ 1 comment

          1 line.

          print(input()==0 or sorted(list(set(map(int,input().split()))))[-2])
          
          8|
          ParentPermalink
          • salvadharani_84 1 year ago+ 0 comments
            [deleted]
            0|
            ParentPermalink
      • bONSPARROW 2 years ago+ 0 comments

        it works.

        0|
        ParentPermalink
      • suryansh_vimale1 9 months ago+ 0 comments

        his code would work for this input , as he is using sets concept in this , the number arent repeated in sets .

        1|
        ParentPermalink
    • jzhou3000 5 months ago+ 2 comments

      How about the case like this: 3 5 5 5 set(nums) will only return one element, [-2] will out of index.

      0|
      ParentPermalink
      • jzhou3000 5 months ago+ 0 comments

        I mean 3 numbers: [5, 5, 5]

        0|
        ParentPermalink
      • Benish 2 months ago+ 0 comments

        GO WITH THIS which does it include any sort or set func ...T.C of O(n) rather than O(logn) for sorting it

        if name == 'main': n = int(input()) arr = map(int, input().split()) list1 = list(set(arr)) max=max(list1[0],list1[1]) secondmax=min(list1[0],list1[1])

            for i in range(2,len(list1)): 
            if list1[i]>max: 
                secondmax=max
                max=list1[i] 
            else: 
                if list1[i]>secondmax: 
                    secondmax=list1[i] 
        
        print(secondmax) 
        
        0|
        ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature