[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
[LeetCode] 2859. Sum of Values at Indices With K Set Bits You are given a 0-indexed integer array nums and an integer k. Return an integer that denotes the sum of elements in nums whose corresponding indices have exactly k set bits in their binary representa 2024-01-24 #leetcode #array #java #bit manipulation
[LeetCode] 2744. Find Maximum Number of String Pairs You are given a 0-indexed array words consisting of distinct strings. The string words[i] can be paired with the string words[j] if: The string words[i] is equal to the reversed string of words[j].0 & 2024-01-16 #leetcode #two pointer #java #string #palindrome
[LeetCode] 2085. Count Common Words With One Occurrence Given two string arrays words1 and words2, return the number of strings that appear exactly once in each of the two arrays. Example 1:Input: words1 = [“leetcode”,”is”,”amazing”,”as”,”is”], words2 2024-01-11 #leetcode #hashmap #java #string
[LeetCode] 2696. Minimum String Length After Removing Substrings You are given a string s consisting only of uppercase English letters. You can apply some operations to this string where, in one operation, you can remove any occurrence of one of the substrings “AB” 2024-01-09 #leetcode #java #string #stack
[LeetCode] 1979. Find Greatest Common Divisor of Array Given an integer array nums, return the greatest common divisor of the smallest number and largest number in nums. The greatest common divisor of two numbers is the largest positive integer that evenl 2024-01-06 #leetcode #java #math #gcd
[LeetCode] 2807. Insert Greatest Common Divisors in Linked List Given the head of a linked list head, in which each node contains an integer value. Between every pair of adjacent nodes, insert a new node with a value equal to the greatest common divisor of them. R 2024-01-05 #leetcode #java #math #gcd #linked list
[LeetCode] 1578. Minimum Time to Make Rope Colorful Alice has n balloons arranged on a rope. You are given a 0-indexed string colors where colors[i] is the color of the ith balloon. Alice wants the rope to be colorful. She does not want two consecutive 2023-12-27 #leetcode #array #java #greedy #string