[LeetCode] 1146. Snapshot Array Implement a SnapshotArray that supports the following interface:SnapshotArray(int length) initializes an array-like data structure with the given length. Initially, each element equals 0.void set(inde 2024-11-14 #leetcode #array #hashmap #java #treemap #binary search #design
[LeetCode] 2080. Range Frequency Queries Design a data structure to find the frequency of a given value in a given subarray. The frequency of a value in a subarray is the number of occurrences of that value in the subarray. Implement the Ran 2024-11-14 #leetcode #array #hashmap #java #binary search #design
[LeetCode] 3239. Minimum Number of Flips to Make Binary Grid Palindromic I You are given an m x n binary matrix grid. A row or column is considered palindromic if its values read the same forward and backward. You can flip any number of cells in grid from 0 to 1, or from 1 t 2024-11-14 #leetcode #array #two pointer #java #matrix
[LeetCode] 2064. Minimized Maximum of Products Distributed to Any Store You are given an integer n indicating there are n specialty retail stores. There are m product types of varying amounts, which are given as a 0-indexed integer array quantities, where quantities[i] re 2024-11-13 #leetcode #array #java #binary search #binary search on answer
[LeetCode] 1385. Find the Distance Value Between Two Arrays Given two integer arrays arr1 and arr2, and the integer d, return the distance value between the two arrays. The distance value is defined as the number of elements arr1[i] such that there is not any 2024-11-13 #leetcode #java #sort #binary search
[LeetCode] 2070. Most Beautiful Item for Each Query You are given a 2D integer array items where items[i] = [pricei, beautyi] denotes the price and beauty of an item respectively. You are also given a 0-indexed integer array queries. For each quer 2024-11-13 #leetcode #array #java #sort #binary search
[LeetCode] 3090. Maximum Length Substring With Two Occurrences Given a string s, return the maximum length of a substring such that it contains at most two occurrences of each character. Example 1:Input: s = “bcbbbcba”Output: 4 Explanation:The following subs 2024-11-09 #leetcode #hashmap #java #sliding window #string
[LeetCode] 2841. Maximum Sum of Almost Unique Subarray You are given an integer array nums and two positive integers m and k. Return the maximum sum out of all almost unique subarrays of length k of nums. If no such subarray exists, return 0. A subarray o 2024-11-09 #leetcode #array #hashmap #java #sliding window #sliding window with fixed size
[LeetCode] 1343. Number of Sub-arrays of Size K and Average Greater than or Equal to Threshold Given an array of integers arr and two integers k and threshold, return the number of sub-arrays of size k and average greater than or equal to threshold. Example 1:Input: arr = [2,2,2,2,5,5,5,8] 2024-11-09 #leetcode #array #java #sliding window #sliding window with fixed size
[LeetCode] 2275. Largest Combination With Bitwise AND Greater Than Zero The bitwise AND of an array nums is the bitwise AND of all integers in nums. For example, for nums = [1, 5, 3], the bitwise AND is equal to 1 & 5 & 3 = 1.Also, for nums = [7], t 2024-11-07 #leetcode #java #bit manipulation