Leetcode
文章平均质量分 62
吴中乐
这个作者很懒,什么都没留下…
展开
-
剑指 Offer 15. 二进制中1的个数(Medium)(JAVA)
剑指 Offer 15. 二进制中1的个数(Medium)(JAVA)题目地址: https://leetcode-cn.com/problems/er-jin-zhi-zhong-1de-ge-shu-lcof/题目描述:请实现一个函数,输入一个整数(以二进制串形式),输出该数二进制表示中 1 的个数。例如,把 9 表示成二进制是 1001,有 2 位是 1。因此,如果输入 9,则该函数输出 2。示例 1:输入:00000000000000000000000000001011输出:3原创 2021-06-23 09:17:28 · 387 阅读 · 0 评论 -
剑指 Offer 38. 字符串的排列(Medium)(JAVA)每日一题
剑指 Offer 38. 字符串的排列(Medium)(JAVA)题目地址: https://leetcode-cn.com/problems/zi-fu-chuan-de-pai-lie-lcof/题目描述:输入一个字符串,打印出该字符串中字符的所有排列。你可以以任意顺序返回这个字符串数组,但里面不能有重复元素。示例:输入:s = "abc"输出:["abc","acb","bac","bca","cab","cba"]限制:1 <= s 的长度 <= 8解题方法要找原创 2021-06-22 09:28:33 · 419 阅读 · 0 评论 -
【LeetCode】 1600. Throne Inheritance 皇位继承顺序(Medium)(JAVA)
【LeetCode】 1600. Throne Inheritance 皇位继承顺序(Medium)(JAVA)题目地址: https://leetcode.com/problems/throne-inheritance/题目描述:A kingdom consists of a king, his children, his grandchildren, and so on. Every once in a while, someone in the family dies or a child is原创 2021-06-20 10:12:38 · 465 阅读 · 0 评论 -
【LeetCode】390. Elimination Game 消除游戏(Medium)(JAVA)
【LeetCode】390. Elimination Game 消除游戏(Medium)(JAVA)题目地址: https://leetcode.com/problems/elimination-game/题目描述:There is a list of sorted integers from 1 to n. Starting from left to right, remove the first number and every other number afterward until you r原创 2020-12-29 09:23:13 · 155 阅读 · 0 评论 -
【LeetCode】389. Find the Difference 找不同(Easy)(JAVA)
【LeetCode】389. Find the Difference 找不同(Easy)(JAVA)题目地址: https://leetcode-cn.com/problems/find-the-difference/题目描述:You are given two strings s and t.String t is generated by random shuffling string s and then add one more letter at a random position.Re原创 2020-12-29 09:22:40 · 148 阅读 · 0 评论 -
【LeetCode】388. Longest Absolute File Path 文件的最长绝对路径(Medium)(JAVA)
【LeetCode】388. Longest Absolute File Path 文件的最长绝对路径(Medium)(JAVA)题目地址: https://leetcode.com/problems/longest-absolute-file-path/题目描述:Suppose we have a file system that stores both files and directories. An example of one system is represented in the fol原创 2020-12-29 09:21:39 · 194 阅读 · 0 评论 -
【LeetCode】387. First Unique Character in a String 字符串中的第一个唯一字符(Easy)(JAVA)
【LeetCode】387. First Unique Character in a String 字符串中的第一个唯一字符(Easy)(JAVA)题目地址: https://leetcode.com/problems/first-unique-character-in-a-string/题目描述:Given a string, find the first non-repeating character in it and return its index. If it doesn’t exist,原创 2020-12-29 09:20:57 · 124 阅读 · 0 评论 -
【LeetCode】386. Lexicographical Numbers 字典序排数(Medium)(JAVA)
【LeetCode】386. Lexicographical Numbers 字典序排数(Medium)(JAVA)题目地址: https://leetcode.com/problems/lexicographical-numbers/题目描述:Given an integer n, return 1 - n in lexicographical order.For example, given 13, return: [1,10,11,12,13,2,3,4,5,6,7,8,9].Please原创 2020-12-29 09:20:21 · 127 阅读 · 0 评论 -
【LeetCode】383. Ransom Note 赎金信(Easy)(JAVA)
【LeetCode】383. Ransom Note 赎金信(Easy)(JAVA)题目地址: https://leetcode.com/problems/ransom-note/题目描述:Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom note原创 2020-12-29 09:19:49 · 200 阅读 · 0 评论 -
【LeetCode】377. Combination Sum IV 组合总和 Ⅳ(Medium)(JAVA)
【LeetCode】377. Combination Sum IV 组合总和 Ⅳ(Medium)(JAVA)题目地址: https://leetcode.com/problems/combination-sum-iv/题目描述:Given an integer array with all positive numbers and no duplicates, find the number of possible combinations that add up to a positive inte原创 2020-12-25 09:08:48 · 215 阅读 · 0 评论 -
【LeetCode】376. Wiggle Subsequence 摆动序列(Medium)(JAVA)
【LeetCode】376. Wiggle Subsequence 摆动序列(Medium)(JAVA)题目地址: https://leetcode.com/problems/wiggle-subsequence/题目描述:A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negat原创 2020-12-25 09:08:10 · 102 阅读 · 0 评论 -
【LeetCode】375. Guess Number Higher or Lower II 猜数字大小 II(Medium)(JAVA)
【LeetCode】375. Guess Number Higher or Lower II 猜数字大小 II(Medium)(JAVA)题目地址: https://leetcode.com/problems/guess-number-higher-or-lower-ii/题目描述:We are playing the Guessing Game. The game will work as follows:I pick a number between 1 and原创 2020-12-25 09:07:33 · 196 阅读 · 0 评论 -
【LeetCode】374. Guess Number Higher or Lower 猜数字大小(Easy)(JAVA)
【LeetCode】374. Guess Number Higher or Lower 猜数字大小(Easy)(JAVA)题目地址: https://leetcode.com/problems/guess-number-higher-or-lower/题目描述:We are playing the Guess Game. The game is as follows:I pick a number from 1 to n. You have to guess which number I picke原创 2020-12-25 09:07:00 · 135 阅读 · 0 评论 -
【LeetCode】373. Find K Pairs with Smallest Sums 查找和最小的K对数字(Medium)(JAVA)
【LeetCode】373. Find K Pairs with Smallest Sums 查找和最小的K对数字(Medium)(JAVA)题目地址: https://leetcode.com/problems/find-k-pairs-with-smallest-sums/题目描述:You are given two integer arrays nums1 and nums2 sorted in ascending order and an integer k.Define a pair (u原创 2020-12-25 09:06:25 · 160 阅读 · 0 评论 -
【LeetCode】372. Super Pow 超级次方(Medium)(JAVA)
【LeetCode】372. Super Pow 超级次方(Medium)(JAVA)题目地址: https://leetcode.com/problems/super-pow/题目描述:Your task is to calculate a^b mod 1337 where a is a positive integer and b is an extremely large positive integer given in the form of an array.Example 1:Inp原创 2020-12-24 09:16:24 · 155 阅读 · 0 评论 -
【LeetCode】371. Sum of Two Integers 两整数之和(Easy)(JAVA)
【LeetCode】371. Sum of Two Integers 两整数之和(Easy)(JAVA)题目地址: https://leetcode.com/problems/sum-of-two-integers/题目描述:Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example 1:Input: a = 1, b = 2Output: 3Ex原创 2020-12-24 09:15:46 · 111 阅读 · 0 评论 -
【LeetCode】368. Largest Divisible Subset 最大整除子集(Medium)(JAVA)
【LeetCode】368. Largest Divisible Subset 最大整除子集(Medium)(JAVA)题目地址: https://leetcode.com/problems/largest-divisible-subset/题目描述:Given a set of distinct positive integers, find the largest subset such that every pair (S_i, S_j) of elements in this subset s原创 2020-12-24 09:15:08 · 191 阅读 · 0 评论 -
【LeetCode】367. Valid Perfect Square 有效的完全平方数(Easy)(JAVA)
【LeetCode】367. Valid Perfect Square 有效的完全平方数(Easy)(JAVA)题目地址: https://leetcode.com/problems/valid-perfect-square/题目描述:Given a positive integer num, write a function which returns True if num is a perfect square else False.Follow up: Do not use any buil原创 2020-12-24 09:14:31 · 162 阅读 · 0 评论 -
【LeetCode】365. Water and Jug Problem 水壶问题(Medium)(JAVA)
【LeetCode】365. Water and Jug Problem 水壶问题(Medium)(JAVA)题目地址: https://leetcode.com/problems/water-and-jug-problem/题目描述:You are given two jugs with capacities x and y litres. There is an infinite amount of water supply available. You need to determine whe原创 2020-12-24 09:13:58 · 189 阅读 · 0 评论 -
【LeetCode】363. Max Sum of Rectangle No Larger Than K 矩形区域不超过 K 的最大数值和(Hard)(JAVA)
【LeetCode】363. Max Sum of Rectangle No Larger Than K 矩形区域不超过 K 的最大数值和(Hard)(JAVA)题目地址: https://leetcode.com/problems/max-sum-of-rectangle-no-larger-than-k/题目描述:Given a non-empty 2D matrix matrix and an integer k, find the max sum of a rectangle in the m原创 2020-12-23 08:48:55 · 142 阅读 · 0 评论 -
【LeetCode】357. Count Numbers with Unique Digits 计算各个位数不同的数字个数(Medium)(JAVA)
【LeetCode】357. Count Numbers with Unique Digits 计算各个位数不同的数字个数(Medium)(JAVA)题目地址: https://leetcode.com/problems/count-numbers-with-unique-digits/题目描述:Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10^n.Example:原创 2020-12-23 08:48:20 · 118 阅读 · 0 评论 -
【LeetCode】354. Russian Doll Envelopes 俄罗斯套娃信封问题(Hard)(JAVA)
【LeetCode】354. Russian Doll Envelopes 俄罗斯套娃信封问题(Hard)(JAVA)题目地址: https://leetcode.com/problems/russian-doll-envelopes/题目描述:You have a number of envelopes with widths and heights given as a pair of integers (w, h). One envelope can fit into another if an原创 2020-12-23 08:47:45 · 168 阅读 · 0 评论 -
【LeetCode】350. Intersection of Two Arrays II 两个数组的交集 II(Easy)(JAVA)
【LeetCode】350. Intersection of Two Arrays II 两个数组的交集 II(Easy)(JAVA)题目地址: https://leetcode.com/problems/intersection-of-two-arrays-ii/题目描述:Given two arrays, write a function to compute their intersection.Example 1:Input: nums1 = [1,2,2,1], nums2 = [2,2原创 2020-12-23 08:47:13 · 139 阅读 · 0 评论 -
【LeetCode】349. Intersection of Two Arrays 两个数组的交集(Easy)(JAVA)
【LeetCode】349. Intersection of Two Arrays 两个数组的交集(Easy)(JAVA)题目地址: https://leetcode.com/problems/intersection-of-two-arrays/题目描述:Given two arrays, write a function to compute their intersection.Example 1:Input: nums1 = [1,2,2,1], nums2 = [2,2]Output:原创 2020-12-23 08:46:42 · 96 阅读 · 0 评论 -
【LeetCode】347. Top K Frequent Elements 前 K 个高频元素(Medium)(JAVA)
【LeetCode】347. Top K Frequent Elements 前 K 个高频元素(Medium)(JAVA)题目地址: https://leetcode.com/problems/top-k-frequent-elements/题目描述:Given a non-empty array of integers, return the k most frequent elements.Example 1:Input: nums = [1,1,1,2,2,3], k = 2Output原创 2020-12-22 08:50:39 · 245 阅读 · 1 评论 -
【LeetCode】345. Reverse Vowels of a String 反转字符串中的元音字母(Easy)(JAVA)
【LeetCode】345. Reverse Vowels of a String 反转字符串中的元音字母(Easy)(JAVA)题目地址: https://leetcode.com/problems/reverse-vowels-of-a-string/题目描述:Write a function that takes a string as input and reverse only the vowels of a string.Example 1:Input: "hello"Output:原创 2020-12-22 08:50:06 · 129 阅读 · 0 评论 -
【LeetCode】344. Reverse String 反转字符串(Easy)(JAVA)
【LeetCode】344. Reverse String 反转字符串(Easy)(JAVA)题目地址: https://leetcode.com/problems/reverse-string/题目描述:Write a function that reverses a string. The input string is given as an array of characters char[].Do not allocate extra space for another array, yo原创 2020-12-22 08:49:28 · 106 阅读 · 0 评论 -
【LeetCode】343. Integer Break 整数拆分(Medium)(JAVA)
【LeetCode】343. Integer Break 整数拆分(Medium)(JAVA)题目地址: https://leetcode.com/problems/integer-break/题目描述:Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum prod原创 2020-12-22 08:49:05 · 217 阅读 · 0 评论 -
【LeetCode】342. Power of Four 4的幂(Easy)(JAVA)
【LeetCode】342. Power of Four 4的幂(Easy)(JAVA)题目地址: https://leetcode.com/problems/power-of-four/题目描述:Given an integer n, return true if it is a power of four. Otherwise, return false.An integer n is a power of four, if there exists an integer x such that原创 2020-12-18 09:06:20 · 137 阅读 · 0 评论 -
【LeetCode】338. Counting Bits 比特位计数(Medium)(JAVA)
【LeetCode】338. Counting Bits 比特位计数(Medium)(JAVA)题目地址: https://leetcode.com/problems/counting-bits/题目描述:Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and r原创 2020-12-18 09:05:46 · 159 阅读 · 0 评论 -
【LeetCode】337. House Robber III 打家劫舍 III(Medium)(JAVA)
【LeetCode】337. House Robber III 打家劫舍 III(Medium)(JAVA)题目地址: https://leetcode.com/problems/house-robber-iii/题目描述:The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the “root.” Besides the root,原创 2020-12-18 09:03:51 · 158 阅读 · 0 评论 -
【LeetCode】336. Palindrome Pairs 回文对(Hard)(JAVA)
【LeetCode】336. Palindrome Pairs 回文对(Hard)(JAVA)题目地址: https://leetcode.com/problems/palindrome-pairs/题目描述:Given a list of unique words, return all the pairs of the distinct indices (i, j) in the given list, so that the concatenation of the two words原创 2020-12-18 09:03:19 · 128 阅读 · 0 评论 -
【LeetCode】335. Self Crossing 路径交叉(Hard)(JAVA)
【LeetCode】335. Self Crossing 路径交叉(Hard)(JAVA)题目地址: https://leetcode.com/problems/self-crossing/题目描述:You are given an array x of n positive numbers. You start at point (0,0) and moves x[0] metres to the north, then x[1] metres to the west, x[2] metres to原创 2020-12-17 09:53:03 · 157 阅读 · 0 评论 -
【LeetCode】334. Increasing Triplet Subsequence 递增的三元子序列(Medium)(JAVA)
【LeetCode】334. Increasing Triplet Subsequence 递增的三元子序列(Medium)(JAVA)题目地址: https://leetcode.com/problems/increasing-triplet-subsequence/题目描述:Given an integer array nums, return true if there exists a triple of indices (i, j, k) such that i < j < k原创 2020-12-17 09:49:53 · 133 阅读 · 0 评论 -
【LeetCode】332. Reconstruct Itinerary 重新安排行程(Medium)(JAVA)
【LeetCode】332. Reconstruct Itinerary 重新安排行程(Medium)(JAVA)题目地址: https://leetcode.com/problems/reconstruct-itinerary/题目描述:Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order原创 2020-12-17 09:25:26 · 147 阅读 · 0 评论 -
【LeetCode】331. Verify Preorder Serialization of a Binary Tree 验证二叉树的前序序列化(Medium)(JAVA)
【LeetCode】331. Verify Preorder Serialization of a Binary Tree 验证二叉树的前序序列化(Medium)(JAVA)题目地址: https://leetcode.com/problems/verify-preorder-serialization-of-a-binary-tree/题目描述:One way to serialize a binary tree is to use pre-order traversal. When we enco原创 2020-12-17 09:25:02 · 142 阅读 · 0 评论 -
【LeetCode】330. Patching Array 按要求补齐数组(Hard)(JAVA)
【LeetCode】330. Patching Array 按要求补齐数组(Hard)(JAVA)题目地址: https://leetcode.com/problems/patching-array/题目描述:Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be f原创 2020-12-17 09:24:15 · 83 阅读 · 0 评论 -
【LeetCode】329. Longest Increasing Path in a Matrix 矩阵中的最长递增路径(Hard)(JAVA)
【LeetCode】329. Longest Increasing Path in a Matrix 矩阵中的最长递增路径(Hard)(JAVA)题目地址: https://leetcode.com/problems/longest-increasing-path-in-a-matrix/题目描述:Given an integer matrix, find the length of the longest increasing path.From each cell, you can either原创 2020-12-17 09:23:47 · 126 阅读 · 0 评论 -
【LeetCode】328. Odd Even Linked List 奇偶链表(Medium)(JAVA)
【LeetCode】328. Odd Even Linked List 奇偶链表(Medium)(JAVA)题目地址: https://leetcode.com/problems/odd-even-linked-list/题目描述:Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node numbe原创 2020-12-16 09:00:50 · 117 阅读 · 0 评论 -
【LeetCode】327. Count of Range Sum 区间和的个数(Hard)(JAVA)
【LeetCode】327. Count of Range Sum 区间和的个数(Hard)(JAVA)题目地址: https://leetcode.com/problems/count-of-range-sum/题目描述:Given an integer array nums, return the number of range sums that lie in [lower, upper] inclusive.Range sum S(i, j) is defined as the sum of原创 2020-12-16 09:00:15 · 168 阅读 · 0 评论