본문 바로가기

전체 글91

[Leetcode/C#] 199. Binary Tree Right Side View 문제링크  https://leetcode.com/problems/binary-tree-right-side-view/?envType=study-plan-v2&envId=top-interview-150  199. Binary Tree Right Side View 637. Average of Levels in Binary Tree 랑 비슷한 개념이라 금방 풀 수 있었다. 637번 문제와 동일한 개념으로 풀면 되는데이 문제는 right side view 에서 봤을때 보이는 node 를 return 하면 되는 문제라서queue.Count 를 한 후 반복문 안에서 dequeue 해주고 마지막 요소일때 그 node 의 값을 result List 에 Add 해줬다.  기억하면 좋을 것 public class Solut.. 2024. 8. 17.
[Leetcode/C#] 637. Average of Levels in Binary Tree 문제링크 https://leetcode.com/problems/average-of-levels-in-binary-tree/?envType=study-plan-v2&envId=top-interview-150 637. Average of Levels in Binary Tree  기억하면 좋을 것  public class Solution { Queue queue = new Queue(); List result = new List(); int sumInSameLevel = 0; int cntInSameLevel = 0; public IList AverageOfLevels(TreeNode root) { queue.Enqueue(root); traverse(.. 2024. 8. 17.
[Leetcode/C#] 530. Minimum Absolute Difference in BST 문제링크  https://leetcode.com/problems/minimum-absolute-difference-in-bst/?envType=study-plan-v2&envId=top-interview-150   530. Minimum Absolute Difference in BST   기억하면 좋을 것 내가 풀고싶은대로 풀었더니 Time Limit Exceeded  에러가 난다. O(n^2)내가 푼 코드 /** * Definition for a binary tree node. * public class TreeNode { * public int val; * public TreeNode left; * public TreeNode right; * public TreeNode(.. 2024. 8. 17.
[React] Create react app 프로젝트에 절대경로 import 설정하기 결론{ "compilerOptions": { "baseUrl": "src" }, "include": ["src"]} tsconfig.json 을 위와 같이 설정하기.최신버전 CRA 는 tsconfig.json 의 일부 설정을 자동으로 인식하고 적용함.특히 baseUrl 과 paths 설정은 추가설정 없이도 작동할 수 있음. CRA 는 웹팩과 바벨 설정을 숨기고 관리하기때문에 일반적으로 설정을 직접 수정하려면 eject 를 하거나 추가 도구를 사용해야한다. 그래서 검색해봤을때 다른 사람들은 craco 같은 도구를 사용해서 CRA 설정을 오버라이드 하는 것 같던데 .. 나는 tsconfig.json 을 위와같이 설정해줬는데 절대경로가 설정됐다.  내 CRA 버전은 5,0.1 이다. CRA 버전 확.. 2024. 7. 28.
[LeetCode/C#] 374. Guess Number Higher or Lower 문제링크  374. Guess Number Higher or Lower  https://leetcode.com/problems/guess-number-higher-or-lower/description/  기억하면 좋을 것 1. 중간값을 구할때 var mid = left - (right - left) / 2 를 하면 오버플로우를 피할 수 있다. 물론 중간값을 left + right / 2 로 구할 수 있다. 그러나 컴퓨터가 32비트 정수를 사용한다면 표현할 수 있는 가장 큰 수는 2^32 로 left + right 했을 때 그 값을 초과할 수 있기때문에 중간값을 구할때 저 식을 많이 쓴다고한다.  2. 32비트 정수에서 첫번째 비트는 부호비트. 나머지 31비트는 수를 표현하는데 사용된다. 따라서 부호있는 .. 2024. 5. 4.
[LeetCode/MSSQL] 262. Trips and Users 문제링크 262. Trips and Users https://leetcode.com/problems/trips-and-users/description/ 기억하면 좋을 것 select request_at day ,round(sum(case when status = 'cancelled_by_driver' or status = 'cancelled_by_client' then 1 else 0 end) / (count(id) * 1.00),2) 'Cancellation Rate' from Trips t where request_at between '2013-10-01' and '2013-10-03' and client_id in (select users_id from Users where banned = 'No'.. 2024. 4. 6.
[MSSQL] JOIN시 ON 절에 조건을 붙여줄 때 주의할 점 INNER JOIN 은 두 테이블에서 조인할 때 , 두 테이블에 모두 지정한 열의 데이터가 있어야한다. OUTER JOIN 은 두 테이블에서 조인할 때, 1개의 테이블에만 데이터가 있어도 결과가 나온다. ON 절은 join 조건을 정의할때 사용하고 Where 은 데이터 필터링을 할 때 사용해야한다. "사용해야한다" 라고 말하는 이유는 이렇게 해야 쿼리를 더 읽기 쉽게 짤 수 있고 잘못된 데이터를 가져오는 것을 막을 수 있기 때문이다. 예시 Inner join 절에 P.ProductID = '2' 같은 필터링 조건을 붙여줬을때는 상관이 없지만 필터링한 결과가 나오지만 같은 조건에 Left outer join 을 한 경우 Left outer join 이 모든 row 를 가져와버린다. 이 경우 P.Produc.. 2024. 3. 31.
[LeetCode/MSSQL] 1327. List the Products Ordered in a Period 문제링크 1327. List the Products Ordered in a Period https://leetcode.com/problems/list-the-products-ordered-in-a-period/description/?envType=study-plan-v2&envId=top-sql-50 LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 풀이과정 생.. 2024. 1. 28.
[LeetCode/MSSQL] 196. Delete Duplicate Emails 문제링크 196. Delete Duplicate Emails https://leetcode.com/problems/delete-duplicate-emails/description/?envType=study-plan-v2&envId=top-sql-50 LeetCode - The World's Leading Online Programming Learning Platform Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com 풀이과정 시도 1. 테이블 GROUP BY email 로 묶어서.. 2024. 1. 28.