Eat Study Love

먹고 공부하고 사랑하라

프로그래밍 10

Remove Duplicates from Sorted List II[Linked List,Two Pointers]

https://leetcode.com/problems/remove-duplicates-from-sorted-list-ii/description/Given the head of a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. Return the linked list sorted as well. Example 1:Input: head = [1,2,3,3,4,4,5]Output: [1,2,5]Example 2:Input: head = [1,1,1,2,3]Output: [2,3] Constraints:The number of nodes in t..

Coding_Practice 2024.09.22

Count the Number of Consistent Strings[E,Array,Hash Table,String,Bit Manipulation,Counting]

https://leetcode.com/problems/count-the-number-of-consistent-strings/description/?envType=daily-question&envId=2024-09-12You are given a string allowed consisting of distinct characters and an array of strings words. A string is consistent if all characters in the string appear in the string allowed.Return the number of consistent strings in the array words. Example 1:Input: allowed = "ab", word..

Coding_Practice 2024.09.12

Count Good Nodes in Binary Tree[Tree,Depth-First Search,Breadth-First Search,Binary Tree]

https://leetcode.com/problems/count-good-nodes-in-binary-tree/Given a binary tree root, a node X in the tree is named good if in the path from root to X there are no nodes with a value greater than X.Return the number of good nodes in the binary tree. Example 1:Input: root = [3,1,4,3,null,1,5]Output: 4Explanation: Nodes in blue are good.Root Node (3) is always a good node.Node 4 -> (3,4) is the ..

Coding_Practice 2024.09.09

Number of Good Leaf Nodes Pairs[Tree,Depth-First Search,Binary Tree]

https://leetcode.com/problems/number-of-good-leaf-nodes-pairs/description/You are given the root of a binary tree and an integer distance. A pair of two different leaf nodes of a binary tree is said to be good if the length of the shortest path between them is less than or equal to distance.Return the number of good leaf node pairs in the tree. Example 1:Input: root = [1,2,3,null,4], distance = ..

Coding_Practice 2024.09.09

Kth Largest Element in a Stream[E,Tree,Design,Binary Search Tree,Heap (Priority Queue),Binary Tree,Data Stream]

https://leetcode.com/problems/kth-largest-element-in-a-stream/description/?envType=daily-question&envId=2024-08-12Design a class to find the kth largest element in a stream. Note that it is the kth largest element in the sorted order, not the kth distinct element.Implement KthLargest class:KthLargest(int k, int[] nums) Initializes the object with the integer k and the stream of integers nums.int..

Coding_Practice 2024.08.12

Adding Spaces to a String[M,ArrayTwo Pointers,String,Simulation]

https://leetcode.com/problems/adding-spaces-to-a-string/description/You are given a 0-indexed string s and a 0-indexed integer array spaces that describes the indices in the original string where spaces will be added. Each space should be inserted before the character at the given index.For example, given s = "EnjoyYourCoffee" and spaces = [5, 9], we place spaces before 'Y' and 'C', which are at..

Coding_Practice 2024.07.26

Jump To Python 2장 연습 문제 [1]

Q1. # 홍길동씨의 과목별 점수는 다음과 같다. 홍길도 씨의 평균 점수를 구해라. # 국어 80점 영어 75점 수학 55점 # 국어 = float(80) # 영어 = float(75) # 수학 = float(55) # 평균 = float((국어 + 영어 + 수학)/3) # 소수점 = '%0.0f' %평균 # print(f'홍길동씨의 평균은 {소수점}점') # print('홍길동씨의 평균은 %s점' %소수점) 소수점을 없애려고 했더니 코드가 좀 조잡해진 듯 하다. Q2. # 자연수 13이 홀수인지 짝수인지 판별해보자 # 자연수 = 13 # if 자연수 % 2 == 1 : # print("%s는(은) 홀수입니다."%자연수) # else : # print("%s는(은) 짝수입니다."%자연수) if문을 아직 ..