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 →

  • vikasbiet3 3 years ago+ 6 comments

    what [-2] does please explain.

    3|
    ParentPermalink
    • salernoa 3 years ago+ 1 comment

      Refers to the second to last element.

      2|
      ParentPermalink
      • konidala_venky11 1 year ago+ 3 comments

        what if there is a repetition of the max number -2 wont work there

        1|
        ParentPermalink
        • ahmetenessemerci 1 year ago+ 0 comments

          code uses a set(only distinct numbers)

          2|
          ParentPermalink
        • sourabhsinha396 6 months ago+ 0 comments

          Set can have only non-repeating values

          0|
          ParentPermalink
        • sourabhsinha396 6 months ago+ 0 comments

          Set can have only non-repeating values

          0|
          ParentPermalink
    • Forbidden_Devil 2 years ago+ 0 comments

      The list can be accessed from last, considering last element of index -1 and second last element of index -2 and so on...

      2|
      ParentPermalink
    • kishornawal13 2 years ago+ 0 comments

      like we have list=['1','4','6','7'] then [-1]=7 and similarly [-2]=6 that all.

      1|
      ParentPermalink
    • siAyush 2 years ago+ 0 comments

      [-2] this is indexing in this case it is used to find number which is second largest number after sorting the list

      1|
      ParentPermalink
    • iMems 2 years ago+ 0 comments

      that's the second item of the list from the right. for example: if you have a list=[1,4,6,9,11] list[-1] returns 11 list[-2] returns 9

      0|
      ParentPermalink
    • sourabhsinha396 6 months ago+ 0 comments

      -ve index signifies starting from last index

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