CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 3191. Minimum Operations to Make Binary Array Elements Equal to One I

You are given a binary array nums. You can do the following operation on the array any number of times (possibly zero): Choose any 3 consecutive elements from the array and flip all of them.Flipping a
2025-03-19
#leetcode #array #java #greedy #bit manipulation

[LeetCode] 2610. Convert an Array Into a 2D Array With Conditions

You are given an integer array nums. You need to create a 2D array from nums satisfying the following conditions: The 2D array should contain only the elements of the array nums.Each row in the 2D arr
2025-03-18
#leetcode #array #hashmap #java

[LeetCode] 2401. Longest Nice Subarray

You are given an array nums consisting of positive integers. We call a subarray of nums nice if the bitwise AND of every pair of elements that are in different positions in the subarray is equal to 0.
2025-03-18
#leetcode #array #java #sliding window #bit manipulation

[LeetCode] 2226. Maximum Candies Allocated to K Children

You are given a 0-indexed integer array candies. Each element in the array denotes a pile of candies of size candies[i]. You can divide each pile into any number of sub piles, but you cannot merge two
2025-03-13
#leetcode #array #java #binary search #binary search on answer

[LeetCode] 3101. Count Alternating Subarrays

You are given a binary array nums. We call a subarray alternating if no two adjacent elements in the subarray have the same value. Return the number of alternating subarrays in nums. Example 1:Input:
2025-03-10
#leetcode #array #java #math

[LeetCode] 3208. Alternating Groups II

There is a circle of red and blue tiles. You are given an array of integers colors and an integer k. The color of tile i is represented by colors[i]:colors[i] == 0 means that tile i is red.c
2025-03-09
#leetcode #array #java #sliding window

[LeetCode] 2269. Find the K-Beauty of a Number

The k-beauty of an integer num is defined as the number of substrings of num when it is read as a string that meet the following conditions: It has a length of k.It is a divisor of num.Given integers
2025-03-09
#leetcode #java #sliding window #sliding window with fixed size #math #string

[LeetCode] 2588. Count the Number of Beautiful Subarrays

You are given a 0-indexed integer array nums. In one operation, you can:Choose two different indices i and j such that 0 <= i, j < nums.length.Choose a non-negative integer k such that the
2025-03-05
#leetcode #hashmap #java #prefix sum #bit manipulation

[LeetCode] 2506. Count Pairs Of Similar Strings

You are given a 0-indexed string array words. Two strings are similar if they consist of the same characters. For example, “abca” and “cba” are similar since both consist of characters ‘a’, ‘b’, and ‘
2025-02-21
#leetcode #array #hashmap #java #two sum #counting sort #string

[LeetCode] 2658. Maximum Number of Fish in a Grid

You are given a 0-indexed 2D matrix grid of size m x n, where (r, c) represents:A land cell if grid[r][c] = 0, orA water cell containing grid[r][c] fish, if grid[r][c] > 0.A fisher can start a
2025-02-16
#leetcode #java #bfs #dfs #flood fill
1234…43

Search

Hexo Fluid