Eat Study Love

먹고 공부하고 사랑하라

C 158

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

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

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

Removing Minimum Number of Magic Beans[M,Array,Greedy,Sorting,Enumeration,Prefix Sum]

https://leetcode.com/problems/removing-minimum-number-of-magic-beans/description/You are given an array of positive integers beans, where each integer represents the number of magic beans found in a particular magic bag.Remove any number of beans (possibly none) from each bag such that the number of beans in each remaining non-empty bag (still containing at least one bean) is equal. Once a bean ..

Coding_Practice 2024.07.26

Longest Non-decreasing Subarray From Two Arrays[M,Array,Dynamic Programming]

https://leetcode.com/problems/longest-non-decreasing-subarray-from-two-arrays/You are given two 0-indexed integer arrays nums1 and nums2 of length n.Let's define another 0-indexed integer array, nums3, of length n. For each index i in the range [0, n - 1], you can assign either nums1[i] or nums2[i] to nums3[i].Your task is to maximize the length of the longest non-decreasing subarray in nums3 by..

Coding_Practice 2024.07.24