![](https://img-blog.csdnimg.cn/20201014180756926.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
【LeetCode_笔记】
文章平均质量分 82
眼高手低王二狗
一个做事没有长性的游戏玩家。
展开
-
【LeetCode】009 Move Zeroes 移零
【题目】Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.For example, given nums = [0, 1, 0, 3, 12], after calling原创 2016-03-08 14:11:43 · 406 阅读 · 0 评论 -
【LeetCode】Best Time to Buy and Sell Stock 程序员炒股 part.3
FINAL PART。填坑。【题目】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 at most k transact原创 2016-06-06 15:36:18 · 573 阅读 · 0 评论 -
【LeetCode】Best Time to Buy and Sell Stock 程序员炒股 part.2
【题目】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 at most two transactions.一个数组pri原创 2016-04-20 19:00:54 · 508 阅读 · 0 评论 -
【LeetCode】Best Time to Buy and Sell Stock 程序员炒股 part.1
【题目一】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原创 2016-03-28 17:54:42 · 495 阅读 · 0 评论 -
【LeetCode】007 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 major原创 2016-03-02 16:50:30 · 753 阅读 · 2 评论 -
【LeetCode】010 番外篇 Dynamic Programming 动态规划
【例一:最优路径】现有表格如上,从坐上走到右下(不重复不回头),每步累加,求累加之和最大是多少。解:首先将最左和最上进行依次的累加。再对空白部分进行填充,红色空格代表当前空格,红格对应表1的数字(如B2=9),分别加上上方数字13以及左方数字15,取两者中较大。即max(13+4,15+4)=19,填充进去19,如此完成接下来的操作。综上,按照红色的路径原创 2016-03-21 20:36:58 · 655 阅读 · 0 评论 -
【LeetCode】001 Nim Game 尼姆游戏
【题目】You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last stone wil原创 2016-03-01 09:53:35 · 435 阅读 · 0 评论 -
【LeetCode】002 Single Number 寻找单身狗
【题目】Given an array of integers, every element appears twice except for one. Find that single one.在一个数组中,每个数字都有另一个与之相同,只有一个例外,请找出它。【解析】一、我的方法(即最笨的方法):把每个数字都检索一遍,检索不到相同的就输出。从原创 2016-03-01 09:55:57 · 435 阅读 · 0 评论 -
【LeetCode】003 Unique Paths 唯一路线
【题目】A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to re原创 2016-03-01 09:56:56 · 435 阅读 · 0 评论 -
【LeetCode】004 First Bad Version 寻找老鼠屎
【题目】You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed base原创 2016-03-01 09:58:13 · 386 阅读 · 0 评论 -
【LeetCode】005 Implement strStr() 函数strStr()的功能实现
【题目】Implement strStr().Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.编写一个函数完成strStr(str1,str2)的功能,即判断字符串str2是否是str1的子串,如果是则该函数返回s原创 2016-03-01 09:58:51 · 400 阅读 · 0 评论 -
【LeetCode】006 Bitwise AND of Numbers Range 区间内整数按位与
【题目】Given a range [m, n] where 0 For example, given the range [5, 7], you should return 4. 令0 【解析】思路一:循环程序如下:int rangeBitwiseAnd(int m, int n) { while(m n &原创 2016-03-01 09:59:31 · 558 阅读 · 0 评论 -
【LeetCode】008 Fraction to Recurring Decimal 六点六六六循环
【题目】Given two integers representing the numerator and denominator of a fraction, return the fraction in string format.If the fractional part is repeating, enclose the repeating part in parentheses原创 2016-03-04 11:39:06 · 471 阅读 · 5 评论 -
【LeetCode】011 Swap Nodes in Pairs 两两换位
【题目】Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant sp原创 2016-06-06 22:59:23 · 538 阅读 · 0 评论