HackerRank – Find the Runner-Up Score! In Hindi

Hacker Rank

HackerRank – Find the Runner-Up Score! In Hindi – Is Post Me HackerRank Ke Python Programming Language Se Related Competitive Questions Ka Answer Hai. Is Post Me HackerRank – Find the Runner-Up Score! , Question No 9 Ko Solve Kiya Gaya Hai.

HackerRank – Python Solution Series Ke Sabhi Questions Ka Solution Codes Ko Diya Jayega. Saath Hi Hindi Me Explain Bhi Kiya Jayega.

Yadi Aapne Abhi Tak Python Full Course In Hindi Read Nhi Kiya Hai To Aap Pahle Wo Kare Nhi To Aapko HackerRank- Python Solution Ke Tutorial Ko Understand Karne Main Dikkat Ho Sakti Hai.

HackerRank – Find the Runner-Up Score!

Task

University Sport day competition me part liye hue sabhi participants ke scores diye hue hai. Aapko runner-up score ka pata lagana hai. Aapko list me participants ke scores ko insert karna hai and second participant ke score ko print karna hai.

Input

First line me n yani ke no of participants ko mention kiya jayega, Second line me ek array ko mention kiya jayega.

Constraints

  • 2 <= n <= 10
  • -100 <= A[i] <= 100

Output

Run up score ko print kare. Second score ko Runner up score kahte hai.

Sample Input 0

5
2 3 6 6 5

Sample Output 0

5

Explanation 0

Ek list diya gya hai [2,3,6,6,5]. Sabse jyada score 6 hai and Second most score 5 hai.

Isliye Runner up Score 5 hai.

Solution

if __name__ == '__main__':
    n = int(input())
    arr = map(int, input().split())
    
    print(sorted(list(set(arr)))[-2])

STEP 1 – variable n me integer input lena hai.

STEP 2 – map function ka use karenge, map function me first parameter me int pass karenge and second parameter me input().split() ka use karenge.

STEP 3 – split function input diye hue integer ko space ke baad split kar deta hai.

STEP 4 upar map function se mile result ko variable arr me store karenge.

STEP 5 – set function me arr ko pass karenge. set function duplicate value ko remove kar deta hai.

STEP 6 – set function ko use karne ke baad, ab value ko list me store kare.

STEP 7 – sorted ka use karke list ko sort kare. sorted function list ko ascending order me represent karta hai.

STEP 8 – ab sorted list ko list slicing [::-2] ka use karke second last element ko print karde.

STEP 9 – [::-2] list me present second last element ko represent karta hai.

STEP 10 – Ab value ko print kare.

Upar Diye Hue Code Ko Aap Apne Code Editor Me Use Kar Sakte Hai And Practice Kar Sakte Hai.

DISCLAIMER

The Above Whole Problem Statement Is Given By Hackerrank.Com But The Solution Is Generated By The masterprograming.com Authority If Any Of The Query Regarding This Post Or Website Fill The Contact Us Form.

-Masterprogramming

Friends Mujhe Umeed Hai Ki Aapko HackerRank – Find the Runner-Up Score!  Ke Bare Mai 100% Jankari Ho Gayi Hogi | Agar Aapko Learn Karne Main Dikkat Aa Rahi Hai To Aap Mujhse Se Contact Kar Sakte Hai |

Leave a Reply

Your email address will not be published. Required fields are marked *