OrderedDict Problem | HackerRank | Python | Collections | OrderedDict
HTML-код
- Опубликовано: 20 авг 2024
- This video is about OrderedDict from collections in Python.
Ordinary dictionary doesn't preserved the insertion order till version python 3.6 but in OrdererdDict() the insertion order are preserved.
stackoverflow....
Problem: www.hackerrank...
Sample Code:www.coderscart...
For 1 : 1 Tutoring
WhatsApp contact : 7278222619
mail: jaiswalsatya93@gmail.com
You can support via UPI : sattujaiswal@okhdfcbank
Follow us on:
Whatsapp:
chat.whatsapp....
Facebook:
/ codingcart
Linkedin:
/ satyendra-jaiswal-9035...
/ codingcart
Instagram:
/ codingcart
#HackerRank #Python #OrdererdDict()
Excellent explanation. Really it's very helpful
Great going bro..very helpful for beginners like me
Thanks for uploading these videos....it’s really helpful
Really helpful, keep it up
thanks for this! subscribed! hope you keep making videos!
Thanks :) More to come!
Thank you 😊
please come up with more videos
Sure dude😊
Jaswal, Your explanation is clear. as a beginner i learned a lot from your videos. Can you please make more videos on hacker rank challenges. I know its bit too much to ask for all but there are more people like me practicing to code but couldn't becoz of incomplete knowledge. your help will be highly appreciated.
Glad you liked it.
Sure will definitely, stay connected.
Keep Learning keep supporting 😊
Whats wrong in my code both expected output and my output are same but its showing wrong answer. Can anyone help me please?
from collections import OrderedDict N=int(input()) ordered_dict=OrderedDict() for i in range(N): string=input() list1=string.split() newstr="" for i in range(len(list1)-1): newstr+=" "+list1[i] if newstr in ordered_dict: ordered_dict[newstr]=ordered_dict[newstr]+int(list1[-1]) else: ordered_dict[newstr]=int(list1[-1])
for key,value in ordered_dict.items(): print(key,str(value))
Kuch samajh nhi aya par achha laga sun k😂😂
can you solve with normal dictionary or you havw to use ordereddict()? my friend told me ordereddict is dead and useless now.
Ordinary dictionary doesn't preserved the insertion order till python version 3.6 Now its updated you can solve with normal dictionary.
Try this:
od=dict()
for i in range(int(input())):
k,v=input().rsplit(' ',1)
if k in od:
od[k]=int(od[k])+int(v)
else:
od[k]=v
for k,v in od.items():
print(k,v)