
LeetCode刷题
Starry_1
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
LeetCode 1. Two Sum
Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may not use the same ...原创 2018-09-17 20:38:39 · 238 阅读 · 4 评论 -
LeetCode 69. Sqrt(x)
Implement int sqrt(int x).Compute and return the square root of x, where x is guaranteed to be a non-negative integer.Since the return type is an integer, the decimal digits are truncated and only...原创 2018-11-11 10:01:34 · 245 阅读 · 0 评论 -
LeetCode 67. Add Binary
Given two binary strings, return their sum (also a binary string).The input strings are both non-empty and contains only characters 1 or 0.public class AddBinarySolution { public String addBi...原创 2018-11-08 19:44:15 · 178 阅读 · 0 评论 -
LeetCode 83. Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.public class Solution { public ListNode deleteDuplicates(ListNode head) { /** * 去除链表中的...原创 2018-11-15 13:42:06 · 124 阅读 · 0 评论 -
LeetCode 70. Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?Note: Given n will be a positive...原创 2018-11-14 22:16:16 · 217 阅读 · 0 评论 -
LeetCode 101. Symmetric Tree
Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric/** * Definition for a binary tree node. ...原创 2018-11-20 22:03:42 · 306 阅读 · 0 评论 -
LeetCode 104. Maximum Depth of Binary Tree
Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.Note: A leaf is a node with no childre...原创 2018-11-22 22:02:42 · 180 阅读 · 0 评论 -
LeetCode 88. Merge Sorted Array
Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume tha...原创 2018-11-17 21:26:34 · 175 阅读 · 0 评论 -
LeetCode 100. Same Tree
Given two binary trees, write a function to check if they are the same or not.Two binary trees are considered the same if they are structurally identical and the nodes have the same value. /** ...原创 2018-11-18 11:01:06 · 191 阅读 · 0 评论 -
LeetCode 108. Convert Sorted Array to Binary Search Tree
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the...原创 2018-11-28 22:06:10 · 176 阅读 · 0 评论 -
LeetCode 107. Binary Tree Level Order Traversal II
Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).Tips:题目说的很绕,说白了相当于树的层次遍历 public List<List<In...原创 2018-11-27 22:11:54 · 171 阅读 · 0 评论 -
LeetCode 110. Balanced Binary Tree
Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as:a binary tree in which the depth of the two subtrees of every node never differ b...原创 2018-11-30 21:02:19 · 180 阅读 · 0 评论 -
LeetCode 58. Length of Last Word
Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the length of last word in the string.If the last word does not exist, return 0.Note: A word is defin...原创 2018-10-21 08:53:16 · 205 阅读 · 0 评论 -
LeetCode 66. Plus One
Given a non-empty array of digits representing a non-negative integer, plus one to the integer.The digits are stored such that the most significant digit is at the head of the list, and each element...原创 2018-10-22 21:28:22 · 172 阅读 · 0 评论 -
LeetCode 7. Reverse Integer
Given a 32-bit signed integer, reverse digits of an integer.Note:Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. ...原创 2018-09-18 09:39:08 · 259 阅读 · 3 评论 -
LeetCode 14. Longest Common Prefix
Write a function to find the longest common prefix string amongst an array of strings.If there is no common prefix, return an empty string "".Note:All given inputs are in lowercase letters a-z....原创 2018-09-24 17:32:46 · 159 阅读 · 0 评论 -
LeetCode 26. Remove Duplicates from Sorted Array
Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length.Do not allocate extra space for another array, you must do this by modifyi...原创 2018-10-01 10:27:44 · 176 阅读 · 0 评论 -
LeetCode 20. Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.An input string is valid if:Open brackets must be closed by the same type of b...原创 2018-09-26 09:18:15 · 178 阅读 · 0 评论 -
LeetCode 9. Palindrome Number
Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.字符串解法public class PalindromeNumberSolution { public boolean isPalindrome(int...原创 2018-09-21 19:01:08 · 163 阅读 · 0 评论 -
LeetCode 13. Roman to Integer
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. For example, two is written as II in Roman numeral, just two one's added together. Twelve is written as, XII, whi...原创 2018-09-22 19:43:33 · 188 阅读 · 0 评论 -
LeetCode 27. Remove Element
Given an array nums and a value val, remove all instances of that value in-place and return the new length.Do not allocate extra space for another array, you must do this by modifying the input arra...原创 2018-10-05 17:54:22 · 165 阅读 · 0 评论 -
LeetCode 28. Implement strStr()
Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Clarification:What should we return when needle is an empty string? Thi...原创 2018-10-06 20:40:01 · 227 阅读 · 1 评论 -
LeetCode 35. Search Insert Position
Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.You may assume no duplicates in the array....原创 2018-10-07 15:48:04 · 215 阅读 · 0 评论 -
LeetCode 53. Maximum Subarray
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.Follow up:If you have figured out the O(n) solution, try cod...原创 2018-10-14 14:47:00 · 147 阅读 · 0 评论 -
LeetCode 21. Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.public class MergeTwoSortedListsSolution { /** ...原创 2018-09-29 15:14:47 · 174 阅读 · 0 评论 -
LeetCode 111. Minimum Depth of Binary Tree
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.Note: A leaf is a node with no childr...原创 2018-12-04 09:32:51 · 192 阅读 · 0 评论