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 →

  • 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