CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 1031. Maximum Sum of Two Non-Overlapping Subarrays

Given an integer array nums and two integers firstLen and secondLen, return the maximum sum of elements in two non-overlapping subarrays with lengths firstLen and secondLen. The array with length firs
2023-04-28
#leetcode #java #array #prefix sum

[LeetCode] 2336. Smallest Number in Infinite Set

You have a set which contains all positive integers [1, 2, 3, 4, 5, …]. Implement the SmallestInfiniteSet class:SmallestInfiniteSet() Initializes the SmallestInfiniteSet object to contain all positive
2023-04-26
#leetcode #java #hashmap #design #heap

[LeetCode] 2418. Sort the People

You are given an array of strings names, and an array heights that consists of distinct positive integers. Both arrays are of length n. For each index i, names[i] and heights[i] denote the name and he
2023-04-25
#leetcode #java #array #hashmap #sort #string

[LeetCode] 2300. Successful Pairs of Spells and Potions

You are given two positive integer arrays spells and potions, of length n and m respectively, where spells[i] represents the strength of the ith spell and potions[j] represents the strength of the jth
2023-04-03
#leetcode #java #array #sort #binary search #binary search on answer

[LeetCode] 1590. Make Sum Divisible by P

Given an array of positive integers nums, remove the smallest subarray (possibly empty) such that the sum of the remaining elements is divisible by p. It is not allowed to remove the whole array. Retu
2023-03-10
#leetcode #java #array #hashmap #MOD #prefix sum

[LeetCode] 2187. Minimum Time to Complete Trips

You are given an array time where time[i] denotes the time taken by the ith bus to complete one trip. Each bus can make multiple trips successively; that is, the next trip can start immediately after
2023-03-08
#leetcode #java #array #binary search #binary search on answer

[LeetCode] 1792. Maximum Average Pass Ratio

There is a school that has classes of students and each class will be having a final exam. You are given a 2D integer array classes, where classes[i] = [passi, totali]. You know beforehand that i
2023-02-19
#leetcode #java #array #greedy #math #heap

[LeetCode] 2331. Evaluate Boolean Binary Tree

You are given the root of a full binary tree with the following properties:Leaf nodes have either the value 0 or 1, where 0 represents False and 1 represents True.Non-leaf nodes have either the value
2023-02-06
#leetcode #tree #dfs #java #postorder #recursion

[LeetCode] 1254. Number of Closed Islands

Given a 2D grid consists of 0s (land) and 1s (water). An island is a maximal 4-directionally connected group of 0s and a closed island is an island totally (all left, top, right, bottom) surrounded b
2023-01-20
#leetcode #bfs #dfs #java #flood fill

[LeetCode] 1814. Count Nice Pairs in an Array

You are given an array nums that consists of non-negative integers. Let us define rev(x) as the reverse of the non-negative integer x. For example, rev(123) = 321, and rev(120) = 21. A pair
2023-01-17
#leetcode #java #array #hashmap #two sum #MOD #math
1…1516171819…43

Search

Hexo Fluid