CNoodle
  • Home
  • Archives
  • Tags
  • About

[LeetCode] 3226. Number of Bit Changes to Make Two Integers Equal

You are given two positive integers n and k. You can choose any bit in the binary representation of n that is equal to 1 and change it to 0. Return the number of changes needed to make n equal to k. I
2024-11-01
#leetcode #java #bit manipulation

[LeetCode] 3216. Lexicographically Smallest String After a Swap

Given a string s containing only digits, return the lexicographically smallest string that can be obtained after swapping adjacent digits in s with the same parity at most once. Digits have the same p
2024-10-29
#leetcode #java #greedy #string

[LeetCode] 951. Flip Equivalent Binary Trees

For a binary tree T, we can define a flip operation as follows: choose any node, and swap the left and right child subtrees. A binary tree X is flip equivalent to a binary tree Y if and only if we can
2024-10-23
#leetcode #java #tree #dfs #recursion

[LeetCode] 3184. Count Pairs That Form a Complete Day I

Given an integer array hours representing times in hours, return an integer denoting the number of pairs i, j where i < j and hours[i] + hours[j] forms a complete day. A complete day is defined as
2024-10-21
#leetcode #array #hashmap #java #two sum #counting sort #MOD

[LeetCode] 910. Smallest Range II

You are given an integer array nums and an integer k. For each index i where 0 <= i < nums.length, change nums[i] to be either nums[i] + k or nums[i] - k. The score of nums is the differenc
2024-10-20
#leetcode #array #java #greedy #sort #math

[LeetCode] 1545. Find Kth Bit in Nth Binary String

Given two positive integers n and k, the binary string Sn is formed as follows:S1 = “0”Si = Si - 1 + “1” + reverse(invert(Si - 1)) for i > 1Where + denotes the concatenation operation, re
2024-10-19
#leetcode #java #recursion #string #simulation

[LeetCode] 908. Smallest Range I

You are given an integer array nums and an integer k. In one operation, you can choose any index i where 0 <= i < nums.length and change nums[i] to nums[i] + x where x is an integer from th
2024-10-19
#leetcode #array #java #math

[LeetCode] 2406. Divide Intervals Into Minimum Number of Groups

You are given a 2D integer array intervals where intervals[i] = [left, right] represents the inclusive interval [left, right]. You have to divide the intervals into one or more groups such that e
2024-10-12
#leetcode #array #java #greedy #sort #heap #line sweep

[LeetCode] 962. Maximum Width Ramp

A ramp in an integer array nums is a pair (i, j) for which i < j and nums[i] <= nums[j]. The width of such a ramp is j - i. Given an integer array nums, return the maximum width of a ramp i
2024-10-10
#leetcode #array #java #stack #monotonic stack

[LeetCode] 2491. Divide Players Into Teams of Equal Skill

You are given a positive integer array skill of even length n where skill[i] denotes the skill of the ith player. Divide the players into n / 2 teams of size 2 such that the total skill of each t
2024-10-04
#leetcode #array #two pointer #java
1…678910…46

Search

Hexo Fluid