본문 바로가기

Python11

[LeetCode] 623. Add One Row to Tree (Python) 623번 문제 링크 https://leetcode.com/problems/add-one-row-to-tree/ Add One Row to Tree - LeetCode 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 문제설명 입력: root (TreeNode), val(int), depth (int) 출력: depth 깊이에 val 값이 추가된 root 트리 * depth가 1이라면 root자리에 node를 추가하고 원래 tree를 새 node의 left subtree로 오게하기 .. 2022. 10. 5.
[LeetCode] 1578. Minimum Time to Make Rope Colorful (Python) 1578번 문제 링크 https://leetcode.com/problems/minimum-time-to-make-rope-colorful/ Minimum Time to Make Rope Colorful - LeetCode 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 문제설명 입력: colors 문자열, neededTime 정수 배열 출력: 풍선제거 최소시간 Alice는 같은 색깔의 풍선이 2개 이상 연속되는 것을 싫어한다고 한다. (성질 머리 하고는..) Bob에게 연속된 풍.. 2022. 10. 4.
[프로그래머스] [1차] 프렌즈4블록 (Python) def return_xy(m,n,board): # 2*2 형태로 사라질 블록의 왼쪽위 블럭의 좌표값 리턴 arr = [] for i in range(m): for j in range(n): if i+1 < m and j+1 < n: if board[i][j] and board[i][j] == board[i][j+1] == board[i+1][j] == board[i+1][j+1]: # 왼쪽위 블록 기준으로 그 값이 0이 아니고 오른쪽, 아래, 오른쪽 아래 블록의 값이 값으면 좌표값 저장 arr.append([i,j]) return arr def check(m,n, board): # 2*2 형태로 사라질 블록이 있는지 확인 for i in range(m): for j in range(n): if i+1 <.. 2022. 6. 9.
[Leetcode] 237. Delete Node in a Linked List [문제] Write a function to delete a node in a singly-linked list. You will not be given access to the head of the list, instead you will be given access to the node to be deleted directly. It is guaranteed that the node to be deleted is not a tail node in the list. [생각] 알고 보면 정말 간단한 문제였는데 순간 뇌정지가 왔네요 ㅋㅋ 이전 node의 정보를 알 수 없는데 이걸 삭제하라고...? Linked List 특성상 다음 node의 정보는 접근 가능하나, 이전 node의 접근은 불가능 합니다. 어.. 2022. 3. 20.