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.
Collections.OrderedDict()
Collections.OrderedDict()
Sort by
recency
|
718 Discussions
|
Please Login in order to post a comment
Here is HackerRank Collections.OrderedDict() in python solution - https://programmingoneonone.com/hackerrank-collections-ordereddict-solution-in-python.html
This is a bit of a wierd question, implying the computer is input lots of different lines instead of just a single input, for _ in range(int(input())): print (input())
from collections import OrderedDict items= OrderedDict() n= int(input()) for _ in range(n): item,space, net_price= input().rpartition(' ') items[item]= items.get(item,0)+ int(net_price) print(*[f"{item} {price}" for item, price in items.items()], sep='\n')
from collections import OrderedDict items = OrderedDict()
number_of_items = int(input())
for _ in range(number_of_items): *item_name_parts , price = input().split() item_name = " ".join(item_name_parts) price = int(price)
for item , total in items.items(): print(f"{item} {total}")