Eat Study Love

먹고 공부하고 사랑하라

코테 32

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

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