본문 바로가기

프로젝트들79

[코딩 테스트] 리트코드207 -Course Schedule (Medium) in Python 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, return fal.. 2021. 6. 2.
[코딩 테스트] 리트코드139 -Word Break (Medium) in Python Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Note that the same word in the dictionary may be reused multiple times in the segmentation 문자열 s와 문자열들의 집합 wordDict가 주어졌을 때, wordDict안의 단어로 s를 만들 수 있는 지 확인! 예시: Input: s = "leetcode", wordDict = ["leet","code"] Output: true Explanation: Return .. 2021. 6. 1.
[코딩 테스트] 리트코드70 - Climbing Stairs (Easy) in Python You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? n 개의 계단을 올라야 목적지에 다다를 수 있다. 한 번에 1개, 혹은 2개 계단씩 오를 수 있다면, 얼마나 다양한 방법으로 목적지에 갈 수 있을까? 예시 Input: n = 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps Constraints 1 >>>>>> 파이썬 1초 평균 연산 1억 따라서 Me.. 2021. 6. 1.
[코딩 테스트] 리트코드 208 - Implement Trie(Prefix Tree) A trie (pronounced as "try") or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker. Implement the Trie class: 트라이 구조를 문제에서 요구하는 대로 구현하세요. Trie() Initializes the trie object. void insert(String word) Inserts the string word into the trie. boolean sear.. 2021. 5. 31.