Python List [:]
파이썬에서 괄호 안의 콜론(:)은 slicing에도 유용하게 쓰이지만, 콜론만 넣을 경우 shallow copy가 만들어진다. slice(start, end, step) myList = [0,1,2,3,4,5,6] print(myList[:]) # 전체 print(myList[4:]) # [4]부터 끝까지 print(myList[:3]) # 처음부터 [2]까지 (index 포함 X) print(myList[-1]) # 마지막 element print(myList[::-1]) # reverse string, -1은 move backward print(myList[3::-1]) # 3 2 1 0 shallow copy soft copy라고도 불리며 original list에 영향을 주지 않고 말그대로 con..
03.Hash Table
HackerRank Hash Tables: Ransom Note arr1(magazine)가 arr2(note)를 포함하면 True maganize = ["one", "two", "three] note = ["one", "two"] >>> True maganize = ["one", "two", "three] note = ["twp", "five"] >>> False collections.Counter from collections import Counter mList = ["a", "b", "c", "b"] mCounter = Counter(mList) mCounter >> Counter({'b': 2, 'a': 1, 'c': 1}) Counter() dict subclass for counting ha..