Eat Study Love

먹고 공부하고 사랑하라

코딩 57

Maximum Level Sum of a Binary Tree[M,Tree,Depth-First Search,Breadth-First Search,Binary Tree]

https://leetcode.com/problems/maximum-level-sum-of-a-binary-tree/Given the root of a binary tree, the level of its root is 1, the level of its children is 2, and so on.Return the smallest level x such that the sum of all the values of nodes at level x is maximal. Example 1:Input: root = [1,7,0,7,-8,null,null]Output: 2Explanation: Level 1 sum = 1.Level 2 sum = 7 + 0 = 7.Level 3 sum = 7 + -8 = -1...

Coding_Practice 2024.07.31

Convert 1D Array Into 2D Array[E,Array,Matrix,Simulation]

https://leetcode.com/problems/convert-1d-array-into-2d-array/description/You are given a 0-indexed 1-dimensional (1D) integer array original, and two integers, m and n. You are tasked with creating a 2-dimensional (2D) array with  m rows and n columns using all the elements from original.The elements from indices 0 to n - 1 (inclusive) of original should form the first row of the constructed 2D ..

Coding_Practice 2024.07.26

Design HashMap[E,Array,Hash Table,Linked List,Design,Hash Function]

https://leetcode.com/problems/design-hashmap/description/Design a HashMap without using any built-in hash table libraries.Implement the MyHashMap class:MyHashMap() initializes the object with an empty map.void put(int key, int value) inserts a (key, value) pair into the HashMap. If the key already exists in the map, update the corresponding value.int get(int key) returns the value to which the s..

Coding_Practice 2024.07.26

Find the Index of the First Occurrence in a String[E,Two Pointers,String,String Matching]

https://leetcode.com/problems/find-the-index-of-the-first-occurrence-in-a-string/description/Given two strings needle and haystack, return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. Example 1:Input: haystack = "sadbutsad", needle = "sad"Output: 0Explanation: "sad" occurs at index 0 and 6.The first occurrence is at index 0, so we return 0.Exa..

Coding_Practice 2024.07.21

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문을 아직 ..