Easy 自己做的,但很慢,代码也不简洁Time:O(N) Space:O(N) 注意一下像hashSet这种collection比较是否相等可以直接用equals方法。 class Solution { public …
分类:LeetCode
LeetCode[22] - Missing Ranges
精力旺盛症。 自己做的时候,想的太复杂,做起了binarysearch,企图节省时间。 下次要算清楚,是否有意义。 binarySearch的确logn,但是在lower 和upper之间的数字,很可能还是O(n). 因…
141. Linked List Cycle
欢迎fork and star:Nowcoder-Repository-github 141. Linked List Cycle 题目 Given a linked list, determine if it has …
[LeetCode] Similar RGB Color 相似的红绿蓝颜色
In the following, every capital letter represents some hexadecimal digit from 0 to f. Th…
LeetCode 216 Combination Sum III
题目描述 Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to …
LeetCode 009 Palindrome Number
题目描述 Determine whether an integer is a palindrome. Do this without extra space. 代码 public static boolean isPal…
[LeetCode] 2. Add Two Numbers 题解
问题描述 给你两个非空链表,分别代表两个非负整数,它们的高低位顺序和链表顺序相反,链表中,每个节点代表一位数,要求将两个链表相加,结果也以链表形式返回。 假设链表都不会以 0 开头,除了 0 本身外。 例子: 输入: (…
868. Binary Gap
题目地址:https://leetcode.com/problems/binary-gap/description/ 大意:找出二进制数中两个1的最大相间位数。 思路:一直右移,找出哪一次移动的位数最多。 class S…
Leetcode46——Permutations
文章作者:Tyan 博客:noahsnail.com | CSDN | 简书 1. 问题描述 Given a collection of distinct numbers,…
Leetcode 150. Evaluate Reverse Polish Notation
Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, , /. Each…
[LeetCode By Go 104]38. Count and Say
题目 The count-and-say sequence is the sequence of integers with the first five terms as following: 1 11 21 1211…
285. Inorder Successor in BST
Problem Given a binary search tree and a node in it, find the in-order successor of that node in the BST. Note…