CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 1750. Minimum Length of String After Deleting Similar Ends

Given a string s consisting only of characters ‘a’, ‘b’, and ‘c’. You are asked to apply the following algorithm on the string any number of times: Pick a non-empty prefix from the string s where all
2024-03-05
#leetcode #two pointer #java #string

[LeetCode] 2368. Reachable Nodes With Restrictions

There is an undirected tree with n nodes labeled from 0 to n - 1 and n - 1 edges. You are given a 2D integer array edges of length n - 1 where edges[i] = [ai, bi] indicates that there is an edge
2024-03-01
#leetcode #array #hashmap #java #bfs #dfs #graph #union find

[LeetCode] 2864. Maximum Odd Binary Number

You are given a binary string s that contains at least one ‘1’. You have to rearrange the bits in such a way that the resulting binary number is the maximum odd binary number that can be created from
2024-02-29
#leetcode #java #greedy #math #string

[LeetCode] 2583. Kth Largest Sum in a Binary Tree

You are given the root of a binary tree and a positive integer k. The level sum in the tree is the sum of the values of the nodes that are on the same level. Return the kth largest level sum in the tr
2024-02-27
#leetcode #java #tree #bfs #sort

[LeetCode] 2476. Closest Nodes Queries in a Binary Search Tree

You are given the root of a binary search tree and an array queries of size n consisting of positive integers. Find a 2D array answer of size n where answer[i] = [mini, maxi]:mini is the largest
2024-02-25
#leetcode #array #java #tree #treemap #binary search #bst

[LeetCode] 2108. Find First Palindromic String in the Array

Given an array of strings words, return the first palindromic string in the array. If there is no such string, return an empty string “”. A string is palindromic if it reads the same forward and backw
2024-02-12
#leetcode #array #two pointer #java #string #palindrome

[LeetCode] 2641. Cousins in Binary Tree II

Given the root of a binary tree, replace the value of each node in the tree with the sum of all its cousins’ values. Two nodes of a binary tree are cousins if they have the same depth with different p
2024-02-07
#leetcode #java #tree #bfs

[LeetCode] LCP 30. 魔塔游戏

LCP 30. 魔塔游戏小扣当前位于魔塔游戏第一层,共有 N 个房间,编号为 0 ~ N-1。每个房间的补血道具/怪物对于血量影响记于数组 nums,其中正数表示道具补血数值,即血量增加对应数值;负数表示怪物造成伤害值,即血量减少对应数值;0 表示房间对血量无影响。 小扣初始血量为 1,且无上限。假定小扣原计划按房间编号升序访问所有房间补血/打怪,为保证血量始终为正值,小扣需对
2024-02-05
#leetcode #array #java #greedy #heap

[LeetCode] 292. Nim Game

You are playing the following Nim Game with your friend:Initially, there is a heap of stones on the table.You and your friend will alternate taking turns, and you go first.On each turn, the person who
2024-02-03
#leetcode #java #math #brainteaser

[LeetCode] 2966. Divide Array Into Arrays With Max Difference

You are given an integer array nums of size n and a positive integer k. Divide the array into one or more arrays of size 3 satisfying the following conditions: Each element of nums should be in exactl
2024-02-01
#leetcode #array #java #greedy #sort
1…910111213…41

Search

Hexo Fluid