146. LRU Cache
้ก็ฎ LeetCode: 146. LRU Cache Design a data structure that follows the constraints of a Least Recently Used (LRU) cache. Implement the LRUCache class: LRUCache(int capacity) Initialize the LRU cache with positive size capacity. int get(int key) Return the value of the key if the key exists, otherwise return -1. void put(int key, int value) Update the value of the key if the key exists. Otherwise, add the key-value
1694B. Paranoid String
้ก็ฎ Codeforces: 1694B: Paranoid String Let’s call a binary string ๐ of length ๐ indexed from 1 to ๐ paranoid if we can obtain a string of length 1 by performing the following two kinds of operations ๐โ1 times in any order : Select any substring of ๐ that is equal to 01, and then replace it with 1. Select any substring of ๐ that is equal
1694A. Creep
้ก็ฎ Codeforces: 1694A: Creep Define the score of some binary string ๐ as the absolute difference between the number of zeroes and ones in it. (for example, ๐= 010001 contains 4 zeroes and 2 ones, so the score of ๐ is $|4โ2|=2$). Define the creepiness of some binary string ๐ as the maximum score among all of its
1693A. Directional Increase
้ก็ฎ Codeforces: 1693A: Directional Increase We have an array of length n. Initially, each element is equal to 0 and there is a pointer located on the first element. We can do the following two kinds of operations any number of times (possibly zero) in any order: If the pointer is not on the last element, increase the element the pointer is currently on by 1. Then move it
2306. Naming a Company
้ก็ฎ LeetCode Problem You are given an array of strings ideas that represents a list of names to be used in the process of naming a company. The process of naming a company is as follows: Choose 2 distinct names from ideas, call them ideaA and ideaB. Swap the first letters of ideaA and ideaB with each other. If both of the new names are not found in the
2305. Fair Distribution of Cookies
้ก็ฎ LeetCode Problem You are given an integer array cookies, where cookies[i] denotes the number of cookies in the ith bag. You are also given an integer k that denotes the number of children to distribute all the bags of cookies to. All the cookies in the same bag must go to the same child and cannot be split up. The unfairness of a distribution is defined as the
2289. Steps to Make Array Non-decreasing
้ก็ฎ LeetCode Problem You are given a 0-indexed integer array nums. In one step, remove all elements nums[i] where nums[i - 1] > nums[i] for all 0 < i < nums.length. Return the number of steps performed until nums becomes a non-decreasing array. ่ชชๆ ้้กๆๅจ็ๅฎ Hint ๅพๆๆณๅบไพ๏ผๆไปฅ็ด้ไธไธใ ไธๅๅ ็ด