전체 글
-
Practice>Python>Itertools>Maximize It!hackerrank.com 2019. 3. 7. 07:20
hackerrank.comMaximize It!Problem link : https://www.hackerrank.com/challenges/maximize-it/problemDifficultiy : Hard TipCartesian product is a key to solve this problem, from 'from itertools import product'Don;t miss that the first item in each K line, is # of NiDo '%' to sum of each itemSave maximum result of '%' Solution from itertools import product lines, mod = map(int, input().split(' ')) i..
-
Practice>Python>Itertools>Iterables and Iteratorshackerrank.com 2019. 3. 4. 13:15
Iterables and IteratorsProblem link : https://www.hackerrank.com/challenges/iterables-and-iterators/problemDifficulty : Medium TipAs we can see from problem description, it's regarding combinationWe might be confused a bit due to that 'a' is appeared only once, or multipleIf 'a' appeared only once, we can resolve it simplyHowever, a appeared in multiple timeswe should generate all combinationand..
-
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..