![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
leetcode
private_void
这个作者很懒,什么都没留下…
展开
-
#26 Remove Duplicates from Sorted Array
题目为:Given a sorted array, 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 in原创 2015-05-11 23:09:06 · 237 阅读 · 0 评论 -
#160 Intersection of Two Linked Lists
题目:Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘原创 2015-05-29 11:34:57 · 309 阅读 · 0 评论 -
#172 Factorial Trailing Zeroes
题目:Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.题解:看到一篇讲解非常好的文章,所以这题就转载吧。对n!做质因数分解n!=2x*3y*5z*...转载 2015-05-31 11:29:49 · 336 阅读 · 0 评论 -
#111 Minimum Depth of Binary Tree & #104 Maximum 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.原创 2015-05-31 11:58:28 · 346 阅读 · 0 评论 -
#219 Contains Duplicate II
题目:Given an array of integers and an integer k, find out whether there there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is a原创 2015-06-02 21:23:43 · 380 阅读 · 0 评论 -
#36 Valid Sudoku
题目:Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.The Sudoku board could be partially filled, where empty cells are filled with the character '.'.A partia原创 2015-06-02 20:12:28 · 334 阅读 · 0 评论 -
#102 Binary Tree Level Order Traversal & #107 Binary Tree Level Order Traversal II
题目:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree {3,9,20,#,#,15,7}, 3 / \ 9原创 2015-06-01 22:24:30 · 377 阅读 · 0 评论 -
#16 3Sum Closest
题目如下:Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target. Return the sum of the three integers. You may assume that each input would hav原创 2015-05-11 23:38:50 · 247 阅读 · 0 评论 -
#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 ne原创 2015-06-03 16:08:22 · 287 阅读 · 0 评论 -
#118 Pascal's Triangle & #119 Pascal's Triangle II
题目:Given an index k, return the kth row of the Pascal's triangle.For example, given k = 3,Return [1,3,3,1].题解:原创 2015-05-31 19:43:07 · 313 阅读 · 0 评论 -
#189 Rotate Array
题目:Rotate an array of n elements to the right by k steps.For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].Note:Try to come up as many solution原创 2015-05-22 09:49:46 · 337 阅读 · 0 评论 -
#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 is symmetric: 1 / \ 2 2 / \ / \3 4 4 3Bu原创 2015-06-02 20:00:45 · 371 阅读 · 0 评论 -
#146 LRU Cache
转自:http://www.cnblogs.com/springfor/p/3869393.html。写在开头,以示尊重。题目:Design and implement a data structure for Least Recently Used (LRU) cache. It should support the following operations: get a转载 2015-06-11 11:36:52 · 501 阅读 · 0 评论 -
#53 Maximum Subarray最大子串和
题目:Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous subarray [4,−原创 2015-05-25 15:55:08 · 245 阅读 · 0 评论 -
#169 Majority Element
题目:Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.You may assume that the array is non-empty and the majority原创 2015-05-26 09:53:35 · 265 阅读 · 0 评论 -
#55 Jump Game
题目:Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.De原创 2015-05-26 10:33:18 · 286 阅读 · 0 评论 -
#88 Merge Sorted Array
题目:Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array.Note:You may assume that nums1 has enough space (size that is greater or equal to m + n) to h原创 2015-05-28 15:14:04 · 241 阅读 · 0 评论 -
#21 Merge Two Sorted Lists
题目:原创 2015-05-29 10:33:33 · 254 阅读 · 0 评论 -
#67 Add Binary
题目:Given two binary strings, return their sum (also a binary string).For example,a = "11"b = "1"Return "100".题解:对两个字符串要从最后一位开始加,注意两字符串长度可能不一致,所以需要有补齐。循环结束后,要判断是否有最后进位public c原创 2015-05-20 10:23:00 · 335 阅读 · 0 评论 -
#155 Min Stack
题目:Design a stack that supports push, pop, top, and retrieving the minimum element in constant time.push(x) -- Push element x onto stack.pop() -- Removes the element on top of the stack.top(原创 2015-05-20 15:39:28 · 269 阅读 · 0 评论 -
#112 Path Sum
题目:Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree原创 2015-05-27 09:53:36 · 243 阅读 · 0 评论 -
#217 Contains Duplicate
题目:Given an array of integers, find if the array contains any duplicates. Your function should return true if any value appears at least twice in the array, and it should return false if every ele原创 2015-05-26 16:08:11 · 284 阅读 · 0 评论 -
#20 Valid Parentheses
题目:Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid.The brackets must close in the correct order, "()" and "()[]{}" are原创 2015-05-27 10:11:38 · 250 阅读 · 0 评论 -
#209 Minimum Size Subarray Sum
题目:Given an array ofnpositive integers and a positive integers, find the minimal length of a subarray of which the sum ≥s. If there isn't one, return 0 instead.For example, given the arr...原创 2015-05-26 17:08:35 · 278 阅读 · 0 评论 -
#27 Remove Element leetcode
Remove Element My SubmissionsQuestion Solution Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be chan原创 2015-05-11 22:33:50 · 307 阅读 · 0 评论 -
#66 Plus One
题目如下:Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at the head of the list.整数按位存储于in原创 2015-05-20 09:59:04 · 315 阅读 · 0 评论 -
#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:原创 2015-05-21 12:16:01 · 262 阅读 · 0 评论 -
#125 Valid Palindrome
题目:Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Panama" is a palindrome."race a car"原创 2015-05-20 18:49:38 · 244 阅读 · 0 评论 -
#28 Implement strStr()
Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Update (2014-11-02):The signature of the function had been updated原创 2015-05-12 10:01:41 · 263 阅读 · 0 评论 -
#17 Letter Combinations of a Phone Number有问题
题目:Given a digit string, return all possible letter combinations that the number could represent.A mapping of digit to letters (just like on the telephone buttons) is given below.Input原创 2015-05-21 15:38:32 · 315 阅读 · 0 评论 -
#168 Excel Sheet Column Title &« Excel Sheet Column Number
#168题目:Given a positive integer, return its corresponding column title as appear in an Excel sheet.For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 ->原创 2015-05-27 17:34:33 · 325 阅读 · 0 评论 -
#83 Remove Duplicates from Sorted List
题目:Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3题解:没啥好说的,这个得遍历一原创 2015-05-21 13:18:55 · 320 阅读 · 0 评论 -
#19 Remove Nth Node From End of List
题目:Given a linked list, remove the nth node from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the原创 2015-05-21 15:05:37 · 227 阅读 · 0 评论 -
#29 Divide Two Integers
题目:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.题解:不用乘,除,模操作完成除法运算。只能加减了,但逐个减效率低,肯定超时,想不出来,参考了http://blog.csdn.net/perf原创 2015-05-21 16:55:15 · 346 阅读 · 0 评论 -
最长回文串问题
题目:Given a string S, find the longest palindromic substring in S.给出一个字符串S,找到一个最长的连续回文串。例如串babcbabcbaccba 最长回文是:abcbabcba这个题目给出3中解法,前两种的都是 O(n^2), 第三种思路是O(n).思路1. 动态规划这里动态规划的思路是 dp[i]...转载 2019-07-11 18:04:38 · 253 阅读 · 0 评论