CNoodle
  • Home
  • Archives
  • Tags
  • About

[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

[LeetCode] 1356. Sort Integers by The Number of 1 Bits

Given an integer array arr. You have to sort the integers in the array in ascending order by the number of 1’s in their binary representation and in case of two or more integers have the same number o
2024-11-06
#leetcode #java #sort #bit manipulation

[LeetCode] 3011. Find if Array Can Be Sorted

In one operation, you can swap any two adjacent elements if they have the same number of set bits. You are allowed to do this operation any number of times (including zero). Return true if you can sor
2024-11-06
#leetcode #array #java #sort #bit manipulation

[LeetCode] 3163. String Compression III

Given a string word, compress it using the following algorithm:Begin with an empty string comp. While word is not empty, use the following operation:Remove a maximum length prefix of word made of a si
2024-11-04
#leetcode #java #string #simulation

[LeetCode] 3226. Number of Bit Changes to Make Two Integers Equal

You are given two positive integers n and k. You can choose any bit in the binary representation of n that is equal to 1 and change it to 0. Return the number of changes needed to make n equal to k. I
2024-11-01
#leetcode #java #bit manipulation
1…45678…43

Search

Hexo Fluid