摘要: 本博客不定期更新 LeetCode 题目总结,所有题目使用 Java 实现,小部分题目也提供 JavaScript 代码。我不追求一行 AC 但是我追求一题多解,比较常规的思路,解释清楚复杂度,代码可读性强。欢迎留言和评论,共同进步。这本是我自己用来复习的笔记,如果也能帮到你,那也是我的福报。 如果 阅读全文
posted @ 2020-03-18 09:02 CNoodle 阅读(2436) 评论(2) 推荐(1) 编辑
摘要: A truck has two fuel tanks. You are given two integers, mainTank representing the fuel present in the main tank in liters and additionalTank represent 阅读全文
posted @ 2024-04-25 04:47 CNoodle 阅读(1) 评论(0) 推荐(0) 编辑
摘要: There are n people in a line queuing to buy tickets, where the 0th person is at the front of the line and the (n - 1)th person is at the back of the l 阅读全文
posted @ 2024-04-10 03:49 CNoodle 阅读(5) 评论(0) 推荐(0) 编辑
摘要: You are given a positive integer n representing the number of nodes of a Directed Acyclic Graph (DAG). The nodes are numbered from 0 to n - 1 (inclusi 阅读全文
posted @ 2024-04-07 05:07 CNoodle 阅读(4) 评论(0) 推荐(0) 编辑
摘要: You are given an integer array nums and a positive integer k. Return the number of subarrays where the maximum element of nums appears at least k time 阅读全文
posted @ 2024-03-30 06:26 CNoodle 阅读(16) 评论(0) 推荐(0) 编辑
摘要: You are given a 0-indexed array nums consisting of positive integers. You can do the following operation on the array any number of times: Choose an i 阅读全文
posted @ 2024-03-14 15:42 CNoodle 阅读(7) 评论(0) 推荐(0) 编辑
摘要: You are given a string title consisting of one or more words separated by a single space, where each word consists of English letters. Capitalize the 阅读全文
posted @ 2024-03-11 12:40 CNoodle 阅读(4) 评论(0) 推荐(0) 编辑
摘要: You are given a 0-indexed string word of length n consisting of digits, and a positive integer m. The divisibility array div of word is an integer arr 阅读全文
posted @ 2024-03-07 14:02 CNoodle 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 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: Pi 阅读全文
posted @ 2024-03-06 01:24 CNoodle 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2024-03-02 03:20 CNoodle 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 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 m 阅读全文
posted @ 2024-03-01 11:21 CNoodle 阅读(39) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2024-02-28 09:44 CNoodle 阅读(3) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2024-02-26 13:30 CNoodle 阅读(4) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2024-02-13 14:03 CNoodle 阅读(11) 评论(0) 推荐(0) 编辑
摘要: 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 co 阅读全文
posted @ 2024-02-08 09:08 CNoodle 阅读(1) 评论(0) 推荐(0) 编辑
摘要: 小扣当前位于魔塔游戏第一层,共有 N 个房间,编号为 0 ~ N-1。每个房间的补血道具/怪物对于血量影响记于数组 nums,其中正数表示道具补血数值,即血量增加对应数值;负数表示怪物造成伤害值,即血量减少对应数值;0 表示房间对血量无影响。 小扣初始血量为 1,且无上限。假定小扣原计划按房间编号升 阅读全文
posted @ 2024-02-06 16:15 CNoodle 阅读(13) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2024-02-04 05:02 CNoodle 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 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 co 阅读全文
posted @ 2024-02-02 12:53 CNoodle 阅读(6) 评论(0) 推荐(0) 编辑
摘要: 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 阅读全文
posted @ 2024-01-25 15:06 CNoodle 阅读(7) 评论(0) 推荐(0) 编辑
摘要: 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[ 阅读全文
posted @ 2024-01-17 02:39 CNoodle 阅读(10) 评论(0) 推荐(0) 编辑
摘要: 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 = 阅读全文
posted @ 2024-01-12 11:46 CNoodle 阅读(7) 评论(0) 推荐(0) 编辑