일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- k8s
- OpenShift
- 컨설팅
- Docker
- Redis
- 생성형 AI
- SpringBoot
- 생성형
- jpa
- 메세지큐
- POD
- 도커
- fastapi
- vue.js
- 로깅
- 쿠버네티스
- 컨설턴트
- 솔루션조사
- Machine Learning
- 오픈시프트
- LLaMa
- GPT
- kubernetes
- 머신러닝
- LeetCode
- vuejs
- fast api
- Python
- BFS
- 리트코드
- Today
- Total
목록코딩테스트 (23)
수 많은 우문은 현답을 만든다
Question : The height of a binary tree is the number of edges between the tree's root and its furthest leaf. For example, the following binary tree is of height 2 input : 3 5 2 1 4 6 7 result : 3 참조 : 원문링크 풀이 : 더보기 def height(root): if root is None: return -1 //0으로 하고 마지막에 맞춰도 된다. left_size = height(root.left) right_size = height(root.right) return 1 + max(left_size, right_size) //핵심은 방문시 +1을 높여..
Write a function that takes the binary representation of an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight). Note: Note that in some languages, such as Java, there is no unsigned integer type. In this case, the input will be given as a signed integer type. It should not affect your implementation, as the integer's internal binary representation is th..
Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space. Example 1: Input: nums = [2,2,1] Output: 1 Example 2: Input: nums = [4,1,2,1,2] Output: 4 Example 3: Input: nums = [1] Output: 1 풀이 더보기 class Solution: def singleNumber(self, nums: List[int]) ..
문제 Given a binary tree, determine if it is height-balanced Example 1: Input: root = [3,9,20,null,null,15,7] Output: true Example 2: Input: root = [1,2,2,3,3,null,null,4,4] Output: false Example 3: Input: root = [] Output: true 풀이 더보기 class Solution: def isBalanced(self, root: Optional[TreeNode]) -> bool: def balance(node): if not node: return 0 left = balance(node.left) right = balance(node.righ..
Given the root of a binary tree, return its maximum depth. A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. Example 1: Input: root = [3,9,20,null,null,15,7] Output: 3 Example 2: Input: root = [1,null,2] Output: 2 풀이 더보기 if not root: return 0 left = self.maxDepth(root.left) right = self.maxDepth(root.right) return max(l..
Given the root of a binary tree, invert the tree, and return its root. Input: root = [4,2,7,1,3,6,9] Output: [4,7,2,9,6,3,1] Example 2: Input: root = [2,1,3] Output: [2,3,1] Example 3: Input: root = [] Output: [] 풀이 더보기 class Solution: def invertTree(self, root: Optional[TreeNode]) -> Optional[TreeNode]: if not root: return None left = self.invertTree(root.left) right = self.invertTree(root.righ..
문제 You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. Example 1: Input: list1 = [1,2,4], list2 = [1,3,4] Output: [1,1,2,3,4,4] Example 2: Input: list1 = [], list2 = [] Output: [] Example 3: Input: list1 = [], list2 = ..
문제 Given the head of a singly linked list, reverse the list, and return the reversed list. 우선 구조를 파악하고 코딩해보자. head의 구조는 어떻게 생겼을까? 펼치기 더보기 head : ListNode{val:1, next:ListNode{val:2, next: None}} 그럼 head는 어떻게 선언을 했을까? 이해를 위해 역으로 생각보자. 펼치기 더보기 head = ListNode(1) head.next = ListNode(2) head.next.next = ListNode(3) 풀이 더보기 # Definition for singly-linked list. # class ListNode: # def __init__(self, v..
Given a string s containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Every close bracket has a corresponding open bracket of the same type. Example 1: Input: s = "()" Output: true Example 2: Input: s = "()[]..