전체 글(334)
-
[Leetcode]2011. Final Value of Variable After Performing Operations
1. problem : https://leetcode.com/problems/final-value-of-variable-after-performing-operations/description/ 2. solution 1 : class Solution { public int finalValueAfterOperations(String[] operations) { int x = 0; for (int i = 0; i java라는 언어를 배우는 도중, 언어의 이해를 높이기 위해 algorithm 문제도 같이 풀고 있다. 이 문제는 String[]배열에 들어있는 원소에 "+"가 들어있다면 x값을 1 더해준다. 아니라면 -1 해준다. 이때, contains라는 method가 사용된다. Solu..
2024.07.26 -
[Leetcode]605. Can Place Flowers
1. Problem : https://leetcode.com/problems/can-place-flowers/?envType=study-plan-v2&envId=leetcode-75 2. Solution1 : class Solution: def canPlaceFlowers(self, flowerbed: List[int], n: int) -> bool: flowerbed.insert(0,0) flowerbed.append(0) count = 0 i = 1 while i 0: if flowerbed[i-1] == 0 and flowerbed[i+1] == 0 and flowerbed[i] == 0: ..
2024.07.25 -
[MySQL] Section2_정리
1. show databases; 현재 내가 가지고 있는 database들을 나열해 준다. 2. creating database ; 내가 만들고자 하는 이름으로 database를 만들어준다. 3. DROP DATABASE ; database를 삭제시킨다. 4. USE ; database를 사용한다. --> workbench에서 database를 직접 더블클릭하는 것과 똑같다. 5. Datatype의 종류는 다양하다. 숫자형은 int가 있고, 문자형은 varchar(100)이 있다. 100글자까지 쓸 수 있다는 이야기다. int는 21억까지 varchar(50)하면 50글자까지 저장가능하다. 6. CREATE TABLE ( name varchar(100), age INT); table을 만드는..
2024.07.25 -
[Leetcode]1431. Kids With the Greatest Number of Candies
1. 문제 :https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/description/?envType=study-plan-v2&envId=leetcode-75 2. 풀이 : class Solution: def kidsWithCandies(self, candies: List[int], extraCandies: int) -> List[bool]: if not candies: return [] max_candies = max(candies) for i in range(len(candies)): if candies[i] + extraCandies >= m..
2024.07.25 -
[Leetcode]894. All Possible Full Binary Trees
1. 문제 : Given an integer n, return a list of all possible full binary trees with n nodes. Each node of each tree in the answer must have Node.val == 0.Each element of the answer is the root node of one possible tree. You may return the final list of trees in any order.A full binary tree is a binary tree where each node has exactly 0 or 2 children. Example 1:Input: n = 7Output: [[0,0,0,null,null,..
2024.07.25 -
[Leetcode]2191. Sort the Jumbled Numbers
1. 문제 :You are given a 0-indexed integer array mapping which represents the mapping rule of a shuffled decimal system. mapping[i] = j means digit i should be mapped to digit j in this system.The mapped value of an integer is the new integer obtained by replacing each occurrence of digit i in the integer with mapping[i] for all 0 2. 풀이 : 내가 풀었던 풀이 :class Solution: def sortJumbled(self, mappin..
2024.07.24