CNoodle
  • Home
  • Archives
  • Tags
  • About

[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 #java #array #hashmap #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 #java #array #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 #java #array #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

[LeetCode] 3216. Lexicographically Smallest String After a Swap

Given a string s containing only digits, return the lexicographically smallest string that can be obtained after swapping adjacent digits in s with the same parity at most once. Digits have the same p
2024-10-29
#leetcode #java #greedy #string

[LeetCode] 951. Flip Equivalent Binary Trees

For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees. A binary tree X is flip equivalent to a binary tree Y if and only if we can
2024-10-23
#leetcode #tree #dfs #java #recursion

[LeetCode] 3184. Count Pairs That Form a Complete Day I

Given an integer array hours representing times in hours, return an integer denoting the number of pairs i, j where i < j and hours[i] + hours[j] forms a complete day. A complete day is defined as
2024-10-21
#leetcode #java #array #hashmap #two sum #counting sort #MOD
1…45678…41

Search

Hexo Fluid