Easy
文章平均质量分 67
BigFatSheep
这个作者很懒,什么都没留下…
展开
-
14. Longest Common Prefix(待补充)
题目描述:Write a function to find the longest common prefix string amongst an array of strings.https://leetcode.com/problems/longest-common-prefix/description/思路分析:找出一个string数组中各个元素共有的最长的前缀。我们原创 2017-11-06 07:56:56 · 156 阅读 · 0 评论 -
13. Roman to Integer
问题描述:Given a roman numeral, convert it to an integer.Input is guaranteed to be within the range from 1 to 3999.https://leetcode.com/problems/roman-to-integer/description/思路分析:将罗马数字转换原创 2017-11-05 09:47:13 · 137 阅读 · 0 评论 -
9. Palindrome Number
题目描述:Determine whether an integer is a palindrome. Do this without extra space.Some hints:Could negative integers be palindromes? (ie, -1)If you are thinking of converting the integer to原创 2017-11-03 07:50:12 · 128 阅读 · 0 评论 -
7. Reverse Integer
问题描述:Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321Have you thought about this?Here are some good questions to ask before coding. Bonus poi原创 2017-11-03 05:13:11 · 135 阅读 · 0 评论 -
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 us原创 2017-11-02 13:21:01 · 170 阅读 · 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 "()[]{}" a原创 2017-11-07 06:46:06 · 161 阅读 · 0 评论 -
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.https://leetcode.com/problems/merge-two-sorted-lis...原创 2017-11-09 01:05:10 · 151 阅读 · 0 评论 -
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 by modifying t原创 2017-11-09 15:57:11 · 135 阅读 · 0 评论 -
27. Remove Element
问题描述Given an array and a value, 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 array in-pla原创 2017-11-11 07:48:20 · 128 阅读 · 0 评论 -
28. Implement strStr()(KMP算法)
问题描述Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. 题目链接:28. Implement strStr()Example1: Input: haystack = “hello”, needle原创 2017-11-11 09:02:08 · 289 阅读 · 0 评论 -
66. Plus One
问题描述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 define原创 2017-11-16 14:58:47 · 139 阅读 · 0 评论 -
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.原创 2017-11-14 05:19:19 · 146 阅读 · 0 评论 -
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 111221 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21.原创 2017-11-15 02:54:30 · 157 阅读 · 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 andsum原创 2017-11-29 15:05:38 · 112 阅读 · 0 评论 -
118. Pascal's Triangle
问题描述Given numRows, generate the first numRows of Pascal’s triangle.For example, given numRows = 5, Return [ [1], [1,1], [1,2,1], [1,3,3,1], [1,4,6,4,1] ]题目链接:思路分析输入一个整原创 2017-11-29 15:32:22 · 175 阅读 · 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,-1,2,1] has原创 2017-11-16 14:40:05 · 129 阅读 · 0 评论 -
67. Add Binary
问题描述Given two binary strings, return their sum (also a binary string).For example, a = "11" b ="1" Return"100". 题目链接思路分析对两个用string格式存储的二进制数进行加和,返回一个二进制数。思路是比对两个字符串的长度,然后直接对长的字符串进行修改,逢二进一,一直到字符串头。如果原创 2017-11-23 08:03:12 · 177 阅读 · 0 评论 -
69. Sqrt(x)
问题描述Implement int sqrt(int x).Compute and return the square root of x.x is guaranteed to be a non-negative integer. 题目链接:思路分析实现开平方功能,要求返回平方根的整数部分。代码class Solution {public: int mySqrt(int x) {原创 2017-11-23 12:00:21 · 129 阅读 · 0 评论 -
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原创 2017-11-23 12:37:13 · 151 阅读 · 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.题目链接:思路分析给出一个已经排序了的链表,要求删除链表原创 2017-11-23 13:29:40 · 122 阅读 · 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+nm + n) to hold add原创 2017-11-23 14:15:51 · 136 阅读 · 0 评论 -
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.Example 1原创 2017-11-23 15:00:27 · 116 阅读 · 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 [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \ 3原创 2017-11-24 03:18:00 · 141 阅读 · 0 评论 -
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.题目链接:思路分析最大深度是从二叉树的根结点到其叶子结点最长的路径。给出一棵二原创 2017-11-24 06:32:49 · 172 阅读 · 0 评论 -
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).For example: Given binary tree [3,9,20,null,null,15原创 2017-11-24 08:22:38 · 165 阅读 · 0 评论 -
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.题目链接:思路分析给出一个已经排序了的数组,将这个数组转化为一棵平衡二叉树(AVL树)。百度百科:平衡二叉树(Self-balancing binary search tree)又被称为AVL树(有别原创 2017-11-25 14:45:19 · 163 阅读 · 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 never differ原创 2017-11-27 14:46:41 · 140 阅读 · 0 评论 -
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. 题目链接:思路分析给出一棵平衡二叉树,要求找到它的最小的深度。最小深度是指原创 2017-11-27 15:07:13 · 183 阅读 · 0 评论 -
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]’.Note: Could you optimize your algorithm to use only O(k) extra space?题目链接:思路分析输入一个整数n,输出原创 2018-01-11 03:48:24 · 112 阅读 · 0 评论 -
121. Best Time to Buy and Sell Stock
问题描述Say you have an array for which the ith element is the price of a given stock on day i.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),原创 2018-01-11 04:26:33 · 109 阅读 · 0 评论 -
122. Best Time to Buy and Sell Stock II
问题描述Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy one原创 2018-01-12 01:54:48 · 127 阅读 · 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" is not a p原创 2018-01-12 02:35:21 · 134 阅读 · 0 评论 -
136. Single Number
问题描述Given an array of integers, every element appears twice except for one. Find that single one.Note: Your algorithm should have a linear runtime complexity. Could you implement it without using extr原创 2018-01-12 02:54:52 · 144 阅读 · 0 评论 -
141. Linked List Cycle
问题描述Given a linked list, determine if it has a cycle in it.Follow up: Can you solve it without using extra space? 题目链接:思路分析给一个链表,在不使用额外空间的情况下判断链表中是否有环。通过使用两个指针,快指针一次走两个结点。如果链表没有环,则快指针到链表尾的时候就可以返回fals原创 2018-01-12 03:55:03 · 114 阅读 · 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() – Get t原创 2018-01-13 02:58:16 · 132 阅读 · 0 评论 -
157. Read N Characters Given Read4
问题描述The API:int read4(char *buf) reads 4 characters at a time from a file.The return value is the actual number of characters read. For example, it returns 3 if there is only 3 characters left in the f原创 2018-01-13 03:30:45 · 230 阅读 · 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 ↘原创 2018-01-23 13:39:16 · 146 阅读 · 0 评论 -
170. Two Sum III - Data structure design
问题描述Design and implement a TwoSum class. It should support the following operations: add and find.add - Add the number to an internal data structure. find - Find if there exists any pair of numbers wh原创 2018-02-01 16:30:38 · 216 阅读 · 0 评论 -
171. Excel Sheet Column Number
问题描述Related to question Excel Sheet Column TitleGiven a column title as appear in an Excel sheet, return its corresponding column number.For example:A -> 1B -> 2C -> 3...Z -> 26AA -> 27AB -> 28原创 2018-02-01 16:41:34 · 116 阅读 · 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!的后面有多少个零。0来自10 = 2*5,组成n!的这些数中,2肯定比5要多的,所以这些数里有多少个5就会有多原创 2018-02-01 17:18:09 · 134 阅读 · 0 评论