Nested Lists | Python | HackerRank

แชร์
ฝัง
  • เผยแพร่เมื่อ 14 ต.ค. 2024

ความคิดเห็น • 163

  • @gauravgrover9264
    @gauravgrover9264 3 ปีที่แล้ว +31

    I really liked the way you explained the logic and the code line by line and step by step, Keep this method alive for all the videos.

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Glad you liked it!

  • @trishasingh8832
    @trishasingh8832 2 ปีที่แล้ว +9

    I watched discussions on hackerrank, so many videos on youtube to explain this question to me but everyone was explaining this in such a complicated way that i thought that this was too difficult for me and was about to give up when i found this video... I truly believe now that if the teacher is great, you'll actually understand and enjoy coding!

    • @codingcart
      @codingcart  2 ปีที่แล้ว +1

      Great to hear that 😊.
      Keep learning keep supporting 😊

  • @karthikvenkataram4790
    @karthikvenkataram4790 ปีที่แล้ว +1

    Thank you Excellent teaching.
    Instead of using another FOR LOOP in the end to just sort the names, we can use,
    for val in sorted(res):
    if m==val[1]
    print(val[0])

    • @codingcart
      @codingcart  ปีที่แล้ว

      Glad it helped😊. Please do share with your friends too😊

  • @bibekanandasahoo3497
    @bibekanandasahoo3497 2 ปีที่แล้ว +1

    res=[]
    grade=[]
    for _ in range(int(input())):
    name = input()
    score = float(input())
    res.append([name,score])
    grade.append(score)
    a=set(grade)
    a.remove(min(a))
    g=[]
    for i in res:
    if i[1]==min(a):
    g.append(i[0])
    for i in sorted(g):
    print(i)
    #i try this and it was also worked

  • @charankumar_07
    @charankumar_07 2 ปีที่แล้ว +1

    Excellent teaching bro. Really I see so many but I can't understand .. once saw your video clear cut explanation.....do like this way of teaching

    • @codingcart
      @codingcart  2 ปีที่แล้ว

      Glad you liked it 😊. Do share with your friends too 🙂

  • @funnydirector4203
    @funnydirector4203 3 ปีที่แล้ว +5

    Awesome Brother.....Keep up the good work...First time got this type video on youtube

  • @trilochanrajesh5339
    @trilochanrajesh5339 3 ปีที่แล้ว +4

    Thanks for such a wonderful explanation. I very much happy after seeing such a video. Thanks

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Glad to hear that

  • @mahimakumari2732
    @mahimakumari2732 2 ปีที่แล้ว +2

    Wow!!! how perfectly you explained each line of the code ,you explained all the logic behind each line so perfectly. Thankyou so much for the explanation. 😇

    • @codingcart
      @codingcart  2 ปีที่แล้ว

      Glad you liked it ☺️. Do share with your friends too 🙂

  • @prashantchaudhary007
    @prashantchaudhary007 2 ปีที่แล้ว +4

    Nice explanation I searched everywhere but all were shortcuts, thanks a lot

    • @codingcart
      @codingcart  2 ปีที่แล้ว +1

      Glad you liked it😊

  • @kumodsharma7235
    @kumodsharma7235 2 ปีที่แล้ว +1

    Wow amazing and simple concept . thanku for your great explanation

  • @healthyliving4530
    @healthyliving4530 3 ปีที่แล้ว +2

    Best Explanation. Thank you so much. you are doing great job

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      You are most welcome

  • @lsgtalk1996
    @lsgtalk1996 3 ปีที่แล้ว +3

    Super kya baat h maza aa gaya

    • @codingcart
      @codingcart  3 ปีที่แล้ว +1

      Glad you liked it :)

  • @manasimca
    @manasimca 3 ปีที่แล้ว +3

    Superb explanation my friend....

  • @gokulprasadthangavel2467
    @gokulprasadthangavel2467 3 ปีที่แล้ว +11

    Such a brilliant explanation

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Glad to hear that😊

  • @ankitamehta3932
    @ankitamehta3932 ปีที่แล้ว +2

    You have made coding so easy.Thankyou so much

    • @codingcart
      @codingcart  ปีที่แล้ว

      Glad you liked it 😊
      Please share it with your friends too😊

  • @abdulahad4693
    @abdulahad4693 ปีที่แล้ว +1

    i really like the way of your explanation .... you explanation is mind blowing........😇😇😇

    • @codingcart
      @codingcart  ปีที่แล้ว

      Glad you liked it 😊.
      Start your linked List problem solving with a simple problem like
      "Palindrome check for a Linked List" with different different approaches.
      Approach 1: using string
      th-cam.com/video/CnH48nmU8BI/w-d-xo.html
      Approach 2: using stack
      th-cam.com/video/litQHGRRSdo/w-d-xo.html
      Approach 3: using list
      th-cam.com/video/71lls_x4VdY/w-d-xo.html
      Approach 4: using two pointer concept
      th-cam.com/video/DxvET45WAgE/w-d-xo.html
      Approach 5: using two pointer and a list
      th-cam.com/video/o-bnjsY2Hck/w-d-xo.html

  • @ManojSingh-qi5tb
    @ManojSingh-qi5tb 2 ปีที่แล้ว +1

    thanks sir its really goad explanation for every one to understood code easily. and its very helpfull for me . u are great

    • @codingcart
      @codingcart  2 ปีที่แล้ว

      Glad to hear that 😊.
      Keep learning keep supporting 😊

  • @KaylaLo
    @KaylaLo ปีที่แล้ว +1

    the explanation is clear, awesome

  • @gogodoc678
    @gogodoc678 3 ปีที่แล้ว +1

    i didn't thought about using sets in the python
    too good sir

  • @shrutijain4014
    @shrutijain4014 3 ปีที่แล้ว +1

    Traceback (most recent call last):
    File "Solution.py", line 10, in
    m=grade[1]
    IndexError: list index out of rangeTraceback (most recent call last):
    File "Solution.py", line 10, in
    m=grade[1]
    IndexError: list index out of range

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      You might be accessing the list value which is out of its range.
      Instead of only posting the error you could have posted your solution too so that anyone could have helped by seeing the code.

    • @shrutijain4014
      @shrutijain4014 3 ปีที่แล้ว +2

      @@codingcart I got the solution. That was indentation error. Thanks a lot

  • @Uchiha_Mako
    @Uchiha_Mako 3 ปีที่แล้ว +2

    Outstanding logic

  • @luciferm-u4e
    @luciferm-u4e ปีที่แล้ว

    l1=[]
    l2=[]
    for i in range(int(input("Enter how many students: "))):
    name=input("Enter your names: ")
    marks=float(input("Enter numbers: "))
    l1.append([name,marks])
    l2.append(marks)
    l2=list(sorted(set(l2)))
    lo=l2[1]
    l3=[]
    for i in l1:
    if lo==i[1]:
    l3.append(i[0])
    l3.sort()
    for i in l3:
    print(i)
    my programme

  • @priteshnikam4981
    @priteshnikam4981 3 ปีที่แล้ว +4

    explanation is great....

  • @sjoanC04
    @sjoanC04 3 ปีที่แล้ว +3

    your explanation helped a lot, thanks. keep up the good work.

  • @anupammishra669
    @anupammishra669 3 ปีที่แล้ว +5

    This is Genious brother. Keep it up! And also solve the placement questions of company if you find !! Thanks again!!👍🏻

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Sure 👍 Please do share with your friends and juniors too :)

  • @entertainmentadda1183
    @entertainmentadda1183 2 ปีที่แล้ว +1

    Very neatly explained. Thank you

  • @nivetha.s9892
    @nivetha.s9892 17 วันที่ผ่านมา +1

    Awesome explanation....🎉🎉

    • @codingcart
      @codingcart  16 วันที่ผ่านมา

      Glad it helped😊. Please do share with your friends too😊

  • @ritikasingh8671
    @ritikasingh8671 3 ปีที่แล้ว +2

    Best explanation ever 🤝🏻🤝🏻

  • @sainath2848
    @sainath2848 3 ปีที่แล้ว +2

    Thank you so much! Clear Explanation.

  • @vaishnavii1763
    @vaishnavii1763 3 ปีที่แล้ว +2

    Really a great video. I understood really well. its very helpful. keep up the good work.
    And pls post more of such videos

  • @zianeabdelkbir1807
    @zianeabdelkbir1807 2 ปีที่แล้ว +1

    good explained. Thank you

  • @gogodoc678
    @gogodoc678 3 ปีที่แล้ว +1

    that set logic in python is too good sir

  • @shivdeepsingh2947
    @shivdeepsingh2947 4 ปีที่แล้ว +4

    Thanks for easy explanation

  • @astitvakesharwani2488
    @astitvakesharwani2488 2 ปีที่แล้ว +1

    bhai kya bath hai yaar you're amazing

    • @codingcart
      @codingcart  2 ปีที่แล้ว

      Keep Learning Keep Supporting :)

  • @anoopmr899
    @anoopmr899 3 ปีที่แล้ว +2

    explanation is really understandable!!

  • @MdRizwanRabbani
    @MdRizwanRabbani 4 ปีที่แล้ว +5

    nice explanation 👌

  • @ZiRo175
    @ZiRo175 3 ปีที่แล้ว +6

    thank you so much, these videos are such a game changer to my learning. keep it up

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Happy to hear that!

  • @saurabhyeola6810
    @saurabhyeola6810 2 ปีที่แล้ว +1

    loved the way of explanation

    • @codingcart
      @codingcart  2 ปีที่แล้ว

      Glad you liked it 😊
      Do share with your friends too. You can also watch the latest video on linked list swap nodes problem from leetcode
      th-cam.com/video/_oJYnuulSL0/w-d-xo.html

  • @ragu6757
    @ragu6757 3 ปีที่แล้ว +1

    wonderful explanation bro i was searching for one like you

  • @andalibjahin8077
    @andalibjahin8077 3 ปีที่แล้ว +1

    thank you brother.... its really helpful to understand

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Keep learning keep supporting 😊

  • @AmanSingh-dx8jc
    @AmanSingh-dx8jc 2 ปีที่แล้ว +1

    Very well explained 🙌🏻❤️

  • @dubbasudha8751
    @dubbasudha8751 2 ปีที่แล้ว +1

    Thank you so much for this easy explanation!

  • @MohamedMedhat-ic5ng
    @MohamedMedhat-ic5ng 2 ปีที่แล้ว +1

    high quality content. thank you so much

  • @abhisingh9818
    @abhisingh9818 3 ปีที่แล้ว +3

    Bro the way u r explaining is on another level 🔥

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Glad you think so!

  • @aparajitakumari2936
    @aparajitakumari2936 3 ปีที่แล้ว +1

    Thank you
    It was very easy to follow.

  • @Harshwardhan43237
    @Harshwardhan43237 ปีที่แล้ว +1

    Really nice explanation

    • @codingcart
      @codingcart  ปีที่แล้ว

      Glad you liked it 😊. Do share with your friends too 😊

  • @HimanshuGupta-ni3pk
    @HimanshuGupta-ni3pk 3 ปีที่แล้ว +1

    great explanation man .. Thanks for the help !!!

  • @anandmalba2485
    @anandmalba2485 3 ปีที่แล้ว +1

    Tqs bro for explaining in a clear manner 👏👏

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Keep learning keep supporting 😊

  • @sourabhkumar-jk3gy
    @sourabhkumar-jk3gy 3 ปีที่แล้ว +1

    Perfect explanation!! Crystal clear

    • @codingcart
      @codingcart  3 ปีที่แล้ว +1

      Glad you think so!

  • @surajrathod6098
    @surajrathod6098 ปีที่แล้ว +1

    nice explanation sir.....

    • @codingcart
      @codingcart  ปีที่แล้ว

      Thanks :) do share with your friends too.

  • @sagarpadhiyar3666
    @sagarpadhiyar3666 3 ปีที่แล้ว +2

    Awesome

  • @alkamankar9813
    @alkamankar9813 2 ปีที่แล้ว +2

    You are a great teacher! What a nice explanation!

    • @codingcart
      @codingcart  2 ปีที่แล้ว

      Thanks 😊. Keep learning and please share with your friends too 😊

  • @SaurabhThapa_EN_
    @SaurabhThapa_EN_ 2 ปีที่แล้ว +1

    Thank you so much sir . The way you explain really cool . 😇🙂

    • @codingcart
      @codingcart  2 ปีที่แล้ว

      Thanks and welcome

  • @navu545
    @navu545 ปีที่แล้ว +1

    recently started learning to code, this was a way better explanation compared to other sources. thanks _/\_

    • @codingcart
      @codingcart  ปีที่แล้ว

      Glad you liked it😊
      Please do share with your friends too 😊

  • @haseebmohammed3728
    @haseebmohammed3728 2 ปีที่แล้ว +1

    Great explanation

    • @codingcart
      @codingcart  2 ปีที่แล้ว

      Glad you liked it 😊. Do share with your friends too 🙂

  • @saurabhanand1997
    @saurabhanand1997 ปีที่แล้ว

    very well explained

  • @sahilbisht3661
    @sahilbisht3661 4 ปีที่แล้ว +5

    Awesome 🔥

  • @harika9895
    @harika9895 3 ปีที่แล้ว +3

    awesome

  • @manojkp935
    @manojkp935 2 ปีที่แล้ว +1

    nice bro thanks for clarity🥰

    • @codingcart
      @codingcart  2 ปีที่แล้ว

      Keep learning and keep supporting 😊

  • @ranjanagajbhiye9280
    @ranjanagajbhiye9280 3 ปีที่แล้ว +1

    You are the best 👌🏻

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Thanks :)
      Keep learning keep supporting .

  • @yousefiazkco1440
    @yousefiazkco1440 3 ปีที่แล้ว

    Thank you so much..really really well explained

  • @oneplusfivephonespecificti6237
    @oneplusfivephonespecificti6237 3 ปีที่แล้ว +1

    Bro your video has really helped me🔥

  • @sougandhs4501
    @sougandhs4501 3 ปีที่แล้ว +2

    Thank you so much! Really well explained!

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Glad it was helpful!

  • @shanthaneturi9191
    @shanthaneturi9191 3 ปีที่แล้ว +3

    excellent

  • @NehaSundavadra
    @NehaSundavadra 6 หลายเดือนก่อน +1

    Thank you sir

  • @gauravrajguru393
    @gauravrajguru393 3 ปีที่แล้ว

    good explaination

  • @somukdutta
    @somukdutta 3 ปีที่แล้ว

    can we procced like this ?
    my_dict = {'adam':21, 'bob':32, 'corey':43, 'darek':26, 'euler':24, 'mark':24, 'gen':24}
    val = list(my_dict.values())
    names = list(my_dict.keys())
    val.remove(min(val))
    second_low = val
    result_val = min(val)
    runner_ups = []
    for key,val in my_dict.items():
    if val == result_val:
    runner_ups.append(key)
    print(sorted(runner_ups))

  • @ruhimuktesar1501
    @ruhimuktesar1501 3 ปีที่แล้ว

    I am getting an error here that float is not transciptable. How to resolve?

  • @tilluwaker57
    @tilluwaker57 3 ปีที่แล้ว +2

    Awesome job dude
    use alphabetical order instead of ascending order

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Thanks for the tip

  • @meenakshis7798
    @meenakshis7798 3 ปีที่แล้ว

    can we also use list comprehension instead of append

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Just give a try😊

  • @naimshaik7107
    @naimshaik7107 3 ปีที่แล้ว +1

    Great man Thanks..

  • @gauravgrover9264
    @gauravgrover9264 3 ปีที่แล้ว

    Sir I have a doubt, In 15th line you have made an empty list of 'name' But we have already a variable with the same 'name' in the 5th line, can you please explain?

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Yes. 5th line name variable is for taking the user input which is used only in that for loop for storing in res, so instead of taking another variable i have taken the same name as list type.. but if you are getting confused you can take different variable name :)

  • @andresyah1155
    @andresyah1155 3 ปีที่แล้ว +2

    thanks bro 👍🏻

  • @avnimahajan4417
    @avnimahajan4417 2 ปีที่แล้ว

    Hi
    can someone explain the code from line number 16.
    I'm not clear with the val is being accessed with the indexing in the nested loop. To access element in nested loop won't it be. How will the for loop iterate with val in res?
    to access the first val in res. won't we write to access the first element inside the inner list:like val[0, 0]

    • @avnimahajan4417
      @avnimahajan4417 2 ปีที่แล้ว

      can someone explain how are they accessing list within list?
      memory of the nested list
      i'm not clear with for loop in line 16

  • @sandipansarkar9211
    @sandipansarkar9211 ปีที่แล้ว +1

    finished watching

  • @dhrubaduttabanik5895
    @dhrubaduttabanik5895 2 ปีที่แล้ว +1

    carry on 😌

  • @romapatel5578
    @romapatel5578 2 ปีที่แล้ว

    excellent explanation sir but ..while submitting code test case 3,4,6,9 are getting failed

    • @codingcart
      @codingcart  2 ปีที่แล้ว

      Share your code.. you might be missing small thing😊

  • @petereziagor7379
    @petereziagor7379 2 ปีที่แล้ว +1

    thank you very much bro

  • @prayagpadwal6831
    @prayagpadwal6831 2 ปีที่แล้ว +1

    Thank you man!

    • @codingcart
      @codingcart  2 ปีที่แล้ว

      Glad you liked it 😊. Please share with your friends too 🙂

  • @mitulsp8873
    @mitulsp8873 2 ปีที่แล้ว

    Error (stderr)
    Traceback (most recent call last):
    File "Solution.py", line 11, in
    TypeError: 'list' objects are unhashable
    getting this error

  • @adnanarafat8041
    @adnanarafat8041 3 ปีที่แล้ว +1

    grade= sorted(set(grade)) , it's not working saying error. help me brother

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Please share your code

    • @adnanarafat8041
      @adnanarafat8041 3 ปีที่แล้ว

      @@codingcart n = int(input())
      res = []
      grade = []
      for i in range(n):
      name = str(input())
      marks = float(input())
      res.append([name, marks])
      grade.append([marks])
      print(res)
      print(grade)
      grade = sorted(set(grade))
      print(grade)
      second_lowest = grade[1]
      print(second_lowest)
      aim_name = []
      for val in res:
      if val == second_lowest:
      name.append(aim_name)
      print(aim_name)
      print(sorted(aim_name))
      for nm in aim_name:
      print(nm)

  • @ruhimuktesar1501
    @ruhimuktesar1501 3 ปีที่แล้ว

    Getting an error of 'float' object is not transcriptable

  • @navaneethnavvi2189
    @navaneethnavvi2189 ปีที่แล้ว

    mark = float(input())
    EOFError: EOF when reading a line.
    I am getting like this sir plz give me solution

  • @utkarshjadhav7979
    @utkarshjadhav7979 6 หลายเดือนก่อน +1

    Thanks!

    • @codingcart
      @codingcart  6 หลายเดือนก่อน

      Glad it helped😊. Please do share with your friends too😊

  • @krutarthpatel6537
    @krutarthpatel6537 3 ปีที่แล้ว +2

    Perfect 👌👌

    • @codingcart
      @codingcart  3 ปีที่แล้ว +1

      Glad you think so!

  • @harshakanoj
    @harshakanoj 3 ปีที่แล้ว +1

    Thank you

  • @abhijitmishra646
    @abhijitmishra646 3 ปีที่แล้ว +3

    Thanks bud

  • @rutikpawar1961
    @rutikpawar1961 3 ปีที่แล้ว

    Traceback (most recent call last):
    File "Solution.py", line 12, in
    m=grade[1]
    IndexError: list index out of range
    this error is coming on m =grade[1]
    please help

    • @samanthamorgan1167
      @samanthamorgan1167 3 ปีที่แล้ว

      perhaps there's an error with your indentation

    • @samanthamorgan1167
      @samanthamorgan1167 3 ปีที่แล้ว

      if __name__ == '__main__':
      result=[]
      grades=[]
      for _ in range(int(input())):
      name = input()
      score = float(input())
      result.append([name,score])
      grades.append(score)
      grades=sorted(set(grades))
      n=grades[1]
      name=[]
      for x in result:
      if x[1]==n:
      name.append(x[0])
      name.sort()
      for y in name:
      print(y)

  • @vijjugamerboy9071
    @vijjugamerboy9071 3 ปีที่แล้ว +1

    Thank you much more

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      You are very welcome

    • @vijjugamerboy9071
      @vijjugamerboy9071 3 ปีที่แล้ว

      @@codingcart bro engineering 1st year what about they will teach

  • @dhivyadharshinij9428
    @dhivyadharshinij9428 2 ปีที่แล้ว

    why am I getting this IndexError: list index out of range

  • @amaniabid4476
    @amaniabid4476 ปีที่แล้ว +1

    thx a lot

  • @prajyotgurav3582
    @prajyotgurav3582 2 ปีที่แล้ว

    excellent. but this code do not run if there are multiple high grades.

  • @kasundhananjaya732
    @kasundhananjaya732 2 ปีที่แล้ว +1

    ❤🙏

  • @ryostyles9904
    @ryostyles9904 2 ปีที่แล้ว

    Great job there. Although I used a different method, your video helped me to link the least with the student name:
    (it got only 7/10 but I'm happy that my own idea worked little. I'll use your idea to improve mine :) )
    if __name__ == '__main__':

    n = int(input("Enter number of students: "))
    data = [] # list of name and score
    jscore = [] # list of just the score


    for i in range(1, n+1):
    name = str(input(f"Enter name of student {i}: "))
    score = float(input(f"Enter the score of student {i}: "))
    lis = [name, score] # to temporarily store each student data entry
    data.append(lis) # added to data list


    for student in data:
    jscore.append(student[1]) # just the list of scores

    least1 = min(jscore) # first least score

    while least1 in jscore:
    # to remove first least score even if it's present multiple times
    jscore.remove(least1)

    least2 = jscore[0] # second least score

    names = [] # to store names of students who have second least score
    for student in data:
    if least2 == student[1]: # matching second least score to students in data list
    names.append(student[0])

    for person in (sorted(names)): # sorting alphabetically and printing each name in new line
    print(person)

    • @codingcart
      @codingcart  2 ปีที่แล้ว +1

      Great 😊 keep learning 🤘🏻

    • @ryostyles9904
      @ryostyles9904 2 ปีที่แล้ว

      here is the modified one:
      if __name__ == '__main__':

      n = int(input())
      data = [] # list of name and score
      jscore = [] # list of just the score


      for i in range(1, n+1):
      name = str(input())
      score = float(input())
      lis = [name, score] # to temporarily store each student data entry
      data.append(lis) # added to data list


      for student in data:
      jscore.append(student[1]) # just the list of scores

      unique = sorted(list(set(jscore)))
      least = unique[1]

      names = [] # to store names of students who have second least score
      for student in data:
      if least == student[1]: # matching second least score to students in data list
      names.append(student[0])

      for person in (sorted(names)): # sorting alphabetically and printing each name in new line
      print(person)

    • @ryostyles9904
      @ryostyles9904 2 ปีที่แล้ว

      Note: Make sure to use sorted function after converting the set into list because if you sort the list first, then convert into set and later covert it back to a list, the order may change and give you wrong answer. So use sorted at last =====>ref: variable "unique"

  • @ramyakotike85
    @ramyakotike85 ปีที่แล้ว +1

    Thank you sir

  • @prasad6700
    @prasad6700 3 ปีที่แล้ว +1

    excellent explanation

    • @codingcart
      @codingcart  3 ปีที่แล้ว

      Glad you liked it!