본문 바로가기

리트코드47

❗️[LEET CODE] 332. Reconstruct Itinerary # Problem You are given a list of airline tickets where tickets[i] = [fromi, toi] represent the departure and the arrival airports of one flight. Reconstruct the itinerary in order and return it. All of the tickets belong to a man who departs from "JFK", thus, the itinerary must begin with "JFK". If there are multiple valid itineraries, you should return the itinerary that has the smallest lexic.. 2021. 4. 10.
[LEET CODE] 78. Subsets # Problem Given an integer array nums of unique elements, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Return the solution in any order. Constraints: 1 2021. 4. 9.
[LEET CODE] 39. Combination Sum # Problem Given an array of distinct integers candidates and a target integer target, return a list of all unique combinations of candidates where the chosen numbers sum to target. You may return the combinations in any order. The same number may be chosen from candidates an unlimited number of times. Two combinations are unique if the frequency of at least one of the chosen numbers is different.. 2021. 4. 9.
[LEET CODE] 77. Combinations # Problem Given two integers n and k, return all possible combinations of k numbers out of the range [1, n]. You may return the answer in any order. Constraints: 1 2021. 4. 9.
❗️[LEET CODE] 46. Permutations ( 객체 복사 ) # Problem Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order. Constraints: 1 List[List[int]]: return list(itertools.permutations(nums)) itertools 모듈의 permutations 함수는 튜플 모음을 반환 # 객체 복사 파이썬에서는 모든 것이 객체이기 때문에 '=' 를 이용하면 객체의 참조가 복사되기 때문에 원래의 값을 변경하면 참조한 값도 변경된다. 리스트의 경우 a[:], a.copy() 를 이용하면 값을 복사한 다른 객체를 생성 복잡한 리스트의 경우 a.copy.deep.. 2021. 4. 7.
[LEET CODE] 17. Letter Combinations of a Phone Number # Problem Given a string containing digits from 2-9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order. A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters. Constraints: 0 List[str]: def dfs(index, path): # 끝까지 탐색하면 백트래킹 if len(path) == len(digits): result.append.. 2021. 4. 7.
반응형