전체 글(334)
-
[Leetcode]334. Increasing Triplet Subsequence(x)
1. problem : https://leetcode.com/problems/increasing-triplet-subsequence/?envType=study-plan-v2&envId=leetcode-75 2. solution1 :def increasingTriplet(nums): first = float('inf') second = float('inf') for num in nums: if num 이 코드는 chat gpt 4o가 짜준 코드이다. 나는 풀지 못했다. 그래서 도움을 받았다. 이 풀이는 first , second를 양의 무한대로 설정하고 , first값을 최솟값에 대응한다. 그다음은 second에 최솟값의 다음값을 대응한다. frist와 second가 ..
2024.07.27 -
[Leetcode]238. Product of Array Except Self
1. problem : https://leetcode.com/problems/product-of-array-except-self/description/?envType=study-plan-v2&envId=leetcode-75 2. solution 1 :class Solution: def productExceptSelf(self, nums: List[int]) -> List[int]: n = len(nums) result = [1] * n # Calculate left products left = 1 for i in range(n): result[i] = left left *= nums[..
2024.07.27 -
[Leetcode]1512. Number of Good Pairs
1. problem : https://leetcode.com/problems/number-of-good-pairs/ 2. solution 1 : public class Solution { public int numIdenticalPairs(int[] nums) { int ans = 0; int[] cnt = new int[101]; for (int num : nums) { ans += cnt[num]++; } return ans; }}이 문제의 solution은 leetcode의 다른 사람이 작성한 solution이다. 이 solution은 매우 특이하다. 그 이유는 cnt라는 101개의 원소가 들어갈 수 있는 ..
2024.07.26 -
[Leetcode]151. Reverse Words in a String
1. problem : https://leetcode.com/problems/reverse-words-in-a-string/description/?envType=study-plan-v2&envId=leetcode-75 2. solution 1 : class Solution: def reverseWords(self, s: str) -> str: s = s.split(" ") s = [i for i in s if i] s.reverse() return " ".join(s)split으로 s를 단어별로 구분하는 리스트를 만들고, 이 리스트에 빈값을 없애준다. 그다음, reverse 시켜서 , 단어의 위치를 역순으로 만들어준 다음. " ". jo..
2024.07.26 -
[MySQL]Section 4
1. table을 만든 후 데이터를 insertion 하는 법 create table ( name varchar(100) , age int); 위의 코드를 이용해 테이블을 만든다. insert into (name, age) values ( "rudgh99",26); 2. table에 data가 잘 기입되었는지 확인하는 법 select * from ; 여기서 * 표시는 all의 뜻이라고 생각함. 3. table에 여러 개의 data를 넣는 법 insert into (name, age) values (name1, age1),(names2, age2),(names3, age3); 4. column에 값을 채울 때, not null 설정하는 법 create table (name varchar..
2024.07.26 -
[Leetcode]345. Reverse Vowels of a String
1. Problem : https://leetcode.com/problems/reverse-vowels-of-a-string/description/?envType=study-plan-v2&envId=leetcode-75 2. Solution 1 : class Solution: def reverseVowels(self, s: str) -> str: vowel_list = ["a","e","i","o","u","A","E","I","O","U"] string_list = list(s) left,right = 0,len(string_list)-1 while left 위 solution은 str을 리스트로 만든 다음, left, right ..
2024.07.26