Python
-
Practice>Python>Collections>Piling Up!hackerrank.com 2019. 2. 28. 13:13
hackerrank.comPiling Up!Problem link : https://www.hackerrank.com/challenges/piling-up/problemDifficulty : Medium TipSimplify the rule of problemIf we assume s[] is a all of sideLength, s[0] or s[-1] should be biggest number in sThis is a key to solve problemTo access easily to head and tail, deque is good to useSolution from collections import deque T = int(input()) def stack(n , s): for max_in..
-
Practice>Python>Sets>Set Mutationshackerrank.com 2019. 2. 27. 13:21
hackerrank.comSet MutationsProblem link : https://www.hackerrank.com/challenges/py-set-mutations/problem?utm_campaign=challenge-recommendation&utm_medium=email&utm_source=24-hour-campaign&h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zenDifficulty : Easy TipThis problem is a bit difficultWe can call a method with a name of it, please see getattr() for more detailge..
-
Practice>Python>Sets>Set .symmetric_difference() Operationhackerrank.com 2019. 2. 27. 12:52
hackerrank.comSet .symmetric_difference() OperationProblem link : https://www.hackerrank.com/challenges/py-set-symmetric-difference-operation/problem?utm_campaign=challenge-recommendation&utm_medium=email&utm_source=24-hour-campaign&h_r=next-challenge&h_v=zen&h_r=next-challenge&h_v=zenDifficulty : Easy TipEasy problem, just use symmetric_difference()Solution input() s1 = set(input().split(' ')) ..
-
Practice>Python>Sets>Set .difference() Operationhackerrank.com 2019. 2. 27. 12:47
hackerrank.comSet .difference() OperationProblem link : https://www.hackerrank.com/challenges/py-set-difference-operation/problem?utm_campaign=challenge-recommendation&utm_medium=email&utm_source=24-hour-campaign&h_r=next-challenge&h_v=zenDifficulty : Easy TipJust use difference() method, it is all you should know to solve this problemSolution input() s1 = set(input().split(' ')) input() s2 = se..
-
Practice>Python>Sets>Set .intersection() Operationhackerrank.com 2019. 2. 27. 12:42
hackerrank.comSet .intersection() OperationProblem link : https://www.hackerrank.com/challenges/py-set-intersection-operation/problem?utm_campaign=challenge-recommendation&utm_medium=email&utm_source=24-hour-campaignDifficulty : Easy TipIf you know intersection() method of set, you can easily solve this problem Solution input() s1 = input().split(' ') ss1 = set(s1) input() s2 = input().split(' '..
-
Practice>Python>Collections>Company Logohackerrank.com 2019. 2. 26. 18:03
hackerrank.comCompany LogoProblem link : https://www.hackerrank.com/challenges/most-commons/problemDifficulty : Medium TipDon't forget we should sort as alphabet order if the occurrence is sameTo do sort, don't sort resultwe can sort input string like belowBefore sort : bbccaaAfter sort : aabbccWe should manage two things together, one is key(such as 'a') and the other is key's number of occurre..
-
Practice>Python>Sets>Set .union() Operationhackerrank.com 2019. 2. 26. 12:52
hackerrank.comSet .union() OperationProblem link : https://www.hackerrank.com/challenges/py-set-union/problemDifficulty : Easy TipIf you understand how set() is used, it's simple questionDon't forget to split string to each item for set() Solution input() s = input() s1 = set(s.split(" ")) input() s = input() s2 = set(s.split(" ")) su = s1.union(s2) print(len(su))
-
Practice>Python>Collections>Word Orderhackerrank.com 2019. 2. 25. 13:16
hackerrank.comWord OrderProblem link : https://www.hackerrank.com/challenges/word-order/problemDifficulty : Medium TipProblem is to check that you utilize defaultdictUse input as a key of defaultdict+1 as per input word Solution from collections import defaultdict dic = defaultdict(int) cnt = int(input()) for _ in range(cnt): w = input() dic[w] += 1 print(len(dic)) v = dic.values() v = list(v) s..