coding test96 [LEET CODE] 743. Network Delay Time ( 다익스트라 알고리즘) # Problem You are given a network of n nodes, labeled from 1 to n. You are also given times, a list of travel times as directed edges times[i] = (ui, vi, wi), where ui is the source node, vi is the target node, and wi is the time it takes for a signal to travel from source to target. We will send a signal from a given node k. Return the time it takes for all the n nodes to receive the signal. If.. 2021. 4. 14. ❗️[LEET CODE] 207. Course Schedule # Problem There are a total of numCourses courses you have to take, labeled from 0 to numCourses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] indicates that you must take course bi first if you want to take course ai. For example, the pair [0, 1], indicates that to take course 0 you have to first take course 1. Return true if you can finish all courses. Otherwise, .. 2021. 4. 10. ❗️[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] 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. 이전 1 ··· 11 12 13 14 15 16 다음 반응형