[파이썬] 2차원리스트 dictionary형으로 바꾸기 2차원으로 구성된 자료형은 dictionary형으로 바꿀 수 있다. L1=[[1,2],[54,5]] L2=[(3,5),(6,7)] L3=([1,2],(7,8)) tempD1=dict(L1) tempD2=dict(L2) tempD3=dict(L3) print(tempD1) print(tempD2) print(tempD3) 더보기 {1: 2, 54: 5} {3: 5, 6: 7} {1: 2, 7: 8} 프로그래밍 문법/python 2020.06.19
[백준]1764 듣보잡 #set,dict,list list는 set과 dictionary 보다 요소를 찾는 속도가 느리다. 1. list(시간초과) N,M=map(int,input().split()) L=[] for i in range(N): L.append(input()) ans=0 ansL=[] for i in range(M): temp=input() if temp in L: ans+=1 ansL.append(temp) L.remove(temp) print(ans) for i in sorted(ansL): print(i) 2. set(통과) N,M=map(int,input().split()) s=set() for i in range(N): word=input() s.add(word) ans=0 ansS=set() for j in range(M):.. 알고리즘/자료구조 2020.06.16