CNoodle
  • Home
  • Archives
  • Tags
  • About

[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 #java #bfs #dfs #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 #array #hashmap #java #two sum #MOD #math

[LeetCode] 1813. Sentence Similarity III

You are given two strings sentence1 and sentence2, each representing a sentence composed of words. A sentence is a list of words that are separated by a single space with no leading or trailing spaces
2023-01-16
#leetcode #array #java #string #queue

[LeetCode] 1833. Maximum Ice Cream Bars

It is a sweltering summer day, and a boy wants to buy some ice cream bars. At the store, there are n ice cream bars. You are given an array costs of length n, where costs[i] is the price of the ith ic
2023-01-07
#leetcode #array #java #counting sort #greedy #sort

[LeetCode] 2244. Minimum Rounds to Complete All Tasks

You are given a 0-indexed integer array tasks, where tasks[i] represents the difficulty level of a task. In each round, you can complete either 2 or 3 tasks of the same difficulty level. Return the mi
2023-01-04
#leetcode #array #hashmap #java #counting sort #greedy #math

[LeetCode] 2389. Longest Subsequence With Limited Sum

You are given an integer array nums of length n, and an integer array queries of length m. Return an array answer of length m where answer[i] is the maximum size of a subsequence that you can take fro
2022-12-25
#leetcode #array #java #greedy #prefix sum #sort #binary search

[LeetCode] 1760. Minimum Limit of Balls in a Bag

You are given an integer array nums where the ith bag contains nums[i] balls. You are also given an integer maxOperations. You can perform the following operation at most maxOperations times: Take any
2022-12-20
#leetcode #array #java #binary search #binary search on answer

[LeetCode] 1207. Unique Number of Occurrences

Given an array of integers arr, return true if the number of occurrences of each value in the array is unique, or false otherwise. Example 1:Input: arr = [1,2,2,1,1,3]Output: trueExplanation: The
2022-11-30
#leetcode #array #hashmap #java

[LeetCode] 1758. Minimum Changes To Make Alternating Binary String

You are given a string s consisting only of the characters ‘0’ and ‘1’. In one operation, you can change any ‘0’ to ‘1’ or vice versa. The string is called alternating if no two adjacent characters ar
2022-11-29
#leetcode #java #greedy #string

[LeetCode] 2225. Find Players With Zero or One Losses

You are given an integer array matches where matches[i] = [winneri, loseri] indicates that the player winneri defeated player loseri in a match. Return a list answer of size 2 where:answer[0] is
2022-11-29
#leetcode #array #hashmap #java #sort
1…1718192021…46

Search

Hexo Fluid