본문 바로가기
[한국기술교육대학교] 스크립트프로그래밍 과제1 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 12.. 2021. 9. 14.
287: Find the Duplicate Number Link : https://leetcode.com/problems/find-the-duplicate-number/solution/ 1. 문제 Given an array of integers nums containing n + 1 integers where each integer is in the range [1, n] inclusive.You must solve the problem without modifying the array nums and uses only constant extra space. There is only one repeated number in nums, return this repeated number. 2. 문제의 조건 1 2021. 8. 5.
LEETCODE 287: Find the Duplicate Number Link : https://leetcode.com/problems/find-the-duplicate-number/solution/ Python 더보기 1 2 3 4 5 6 7 8 class Solution: def findDuplicate(self, nums: list[int]) -> int: arr = dict() for i in nums: if i not in arr: arr[i] = True else: return i cs FeedBack cjw.git@gmail.com 2021. 8. 5.
128: Longest Consecutive Sequence Link : https://leetcode.com/problems/longest-consecutive-sequence/ 1. 문제 Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence. You must write an algorithm that runs in O(n) time. 2. 문제의 조건 0 2021. 8. 5.
LEETCODE 128. Longest Consecutive Sequence Link : https://leetcode.com/problems/longest-consecutive-sequence/ Python 더보기 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 class Solution: def DFS(self, start, length): if start not in self.memory or self.memory[start]: return length self.memory[start] = True return self.DFS(start + 1, length + 1) def longestConsecutive(self, nums: list[int]) -> int: self.memory = dict() for n in num.. 2021. 8. 5.