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
  • Hiring developers?
  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 →

  • eduardo_prz_gmz 2 years ago+ 3 comments

    Nice, I didn't think of the set function. Here is my aproach:

    if __name__ == '__main__':
        n = int(input())
        arr = map(int, input().split())
        
        list = list(arr)
        l = [x for x in list if x != max(list)]
        print(max(l))
    
    18|
    ParentPermalink
    • jae_duk_seo 2 years ago+ 0 comments

      This is very interesing solution

      1|
      ParentPermalink
    • goyalnitin634 12 months ago+ 0 comments

      Its always good to see List Comprehensions. But don't you think this will increase overall runtime ? I mean you are creating a new list and then finding the max. of it!

      0|
      ParentPermalink
    • sonofhotmale 10 months ago+ 0 comments

      Nice! Here's an even shorter version using your approach:

      if name == 'main': n = int(input()) arr = list(map(int, input().split())) print(max([x for x in arr if x != max(arr)]))

      0|
      ParentPermalink
  • Contest Calendar
  • Blog
  • Scoring
  • Environment
  • FAQ
  • About Us
  • Support
  • Careers
  • Terms Of Service
  • Privacy Policy
  • Request a Feature