LeetCode
文章平均质量分 59
HandsomeChow
这个作者很懒,什么都没留下…
展开
-
LeetCode-Reverse Integer
Reverse digits of an integer.Example1: x = 123, return 321Example2: x = -123, return -321 click to show spoilers.Have you thought about this?Here are some good questions to ask before coding原创 2017-09-23 14:39:49 · 176 阅读 · 0 评论 -
Leetcode Best Time to Buy and Sell Stock III
题目:Say you have an array for which the ith element is the price of a given stock on dayi.Design an algorithm to find the maximum profit. You may complete at mosttwo transactions.Note:原创 2018-01-12 18:11:41 · 257 阅读 · 0 评论 -
Leetcode 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 dayi.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie原创 2018-01-12 17:11:29 · 241 阅读 · 0 评论 -
Leetcode 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 dayi.If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the原创 2018-01-12 16:43:34 · 175 阅读 · 0 评论 -
Leetcode_Divide Two Integers
题目:Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT.最直接的方法是,用加减法。除了加减乘除,我们还可以用的是,位算法。位算法可以使得计算速度更快。答案:class Solution {public原创 2017-12-17 20:03:08 · 177 阅读 · 0 评论 -
Leetcode-Longest Common Prefix
题目:Write a function to find the longest common prefix string amongst an array of strings.要求找出所有string的最长前缀。可以选择横向比较,两两比较找出最长的前缀,不断比较,不断更新,但考虑了极端情况,假设相同的最长前缀呈阶梯分布,则做了许多无用功。纵向逐个字符比较,显然简单许多。代码如下:cl原创 2017-12-24 12:46:18 · 172 阅读 · 0 评论 -
//Leedcode-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 all原创 2017-11-26 20:27:07 · 152 阅读 · 0 评论 -
Leetcode_3Sum Closest
题目:Given an array S ofn integers, find three integers inS 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 have原创 2017-12-10 20:46:51 · 282 阅读 · 0 评论 -
Leetcode-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 string, note原创 2017-10-14 22:36:44 · 328 阅读 · 0 评论 -
Leetcode-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 in place with constant memory原创 2017-10-31 21:11:38 · 211 阅读 · 0 评论 -
Leetcode_3Sum
Given an array S of n integers, are there elements a,b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note: The solution set must not contain du原创 2017-10-23 19:59:20 · 245 阅读 · 0 评论 -
Leetcode-Longest Substring Without Repeating Characters
题目:Given a string, find the length of the longest substring without repeating characters.Examples:Given "abcabcbb", the answer is "abc", which the length is 3.Given "bbbbb", the answer is "...原创 2017-09-29 11:19:15 · 244 阅读 · 0 评论 -
LeetCode-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 ...原创 2017-09-10 20:16:15 · 239 阅读 · 0 评论 -
Leetcode-Add Two Numbers
question:You are given two non-empty linked lists representing two non-negative integers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers原创 2017-09-16 17:19:19 · 242 阅读 · 0 评论 -
Leetcode-Search a 2D Matrix II
Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties:Integers in each row are sorted in ascending from left to right.Integers i原创 2018-01-12 18:27:39 · 197 阅读 · 0 评论