CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 1647. Minimum Deletions to Make Character Frequencies Unique

A string s is called good if there are no two different characters in s that have the same frequency. Given a string s, return the minimum number of characters you need to delete to make s good. The f
2023-11-21
#leetcode #hashmap #java #greedy #sort #string

[LeetCode] 2216. Minimum Deletions to Make Array Beautiful

You are given a 0-indexed integer array nums. The array nums is beautiful if:nums.length is even.nums[i] != nums[i + 1] for all i % 2 == 0.Note that an empty array is considered beautif
2023-11-21
#leetcode #array #java #greedy #stack

[LeetCode] 2785. Sort Vowels in a String

Given a 0-indexed string s, permute s to get a new string t such that:All consonants remain in their original places. More formally, if there is an index i with 0 <= i < s.length such that
2023-11-13
#leetcode #java #counting sort #sort #string

[LeetCode] 1334. Find the City With the Smallest Number of Neighbors at a Threshold Distance

There are n cities numbered from 0 to n-1. Given the array edges where edges[i] = [fromi, toi, weighti] represents a bidirectional and weighted edge between cities fromi and toi, and given the in
2023-11-13
#leetcode #java #dynamic programming #graph #dijkstra

[LeetCode] 2849. Determine if a Cell Is Reachable at a Given Time

You are given four integers sx, sy, fx, fy, and a non-negative integer t. In an infinite 2D grid, you start at the cell (sx, sy). Each second, you must move to any of its adjacent cells. Return true i
2023-11-08
#leetcode #java #math

[LeetCode] 2609. Find the Longest Balanced Substring of a Binary String

You are given a binary string s consisting only of zeroes and ones. A substring of s is considered balanced if all zeroes are before ones and the number of zeroes is equal to the number of ones inside
2023-11-07
#leetcode #two pointer #java #string

[LeetCode] 2265. Count Nodes Equal to Average of Subtree

Given the root of a binary tree, return the number of nodes where the value of the node is equal to the average of the values in its subtree. Note:The average of n elements is the sum of the n element
2023-11-06
#leetcode #java #tree #dfs #postorder

[LeetCode] 1535. Find the Winner of an Array Game

Given an integer array arr of distinct integers and an integer k. A game will be played between the first two elements of the array (i.e. arr[0] and arr[1]). In each round of the game, we compare arr[
2023-11-05
#leetcode #array #java #simulation

[LeetCode] 2149. Rearrange Array Elements by Sign

You are given a 0-indexed integer array nums of even length consisting of an equal number of positive and negative integers. You should rearrange the elements of nums such that the modified array foll
2023-11-04
#leetcode #array #two pointer #java #simulation

[LeetCode] 2558. Take Gifts From the Richest Pile

You are given an integer array gifts denoting the number of gifts in various piles. Every second, you do the following: Choose the pile with the maximum number of gifts.If there is more than one pile
2023-10-28
#leetcode #array #java #heap #simulation
1…1415161718…46

Search

Hexo Fluid