摘要: 题目: 给定一个字符串,找到不重复字符的最长子字符串的长度。 例如,对于“abcabcbb”,不重复字母的最长子字符串是“abc”,长度为3.对于“bbbbb”,最长子字符串是“b”,长度为1。 思路:由于这个题目只要给出最长不重复子串的长度,所以代码比较简单。第一思路就是利用哈希表来进行操作。用字 阅读全文
posted @ 2017-02-02 11:13 Kobe10 阅读(4952) 评论(0) 推荐(0) 编辑
摘要: 题目: 给定一个三角形,找到从上到下的最小路径总和。 您可以将每个步骤移动到下面一行中的相邻数字。 例如,给定以下三角形 [ [2], [3,4], [6,5,7], [4,1,8,3] ]] 从顶部到底部的最小路径总和为11(即,2 + 3 + 5 + 1 = 11)。 注意: 奖励点,如果你能够 阅读全文
posted @ 2017-02-02 10:36 Kobe10 阅读(714) 评论(0) 推荐(0) 编辑
摘要: 题目一: 给定排序的链表,删除所有重复,使每个元素只出现一次。 例如, 给定1-> 1-> 2,return1-> 2。 给定1-> 1-> 2-> 3-> 3,return1-> 2-> 3。 代码: /** * Definition for singly-linked list. * struc 阅读全文
posted @ 2017-01-30 11:27 Kobe10 阅读(598) 评论(0) 推荐(0) 编辑
摘要: 题目:判断一颗二叉树是否为BST。 思路:其实这个问题可以有多个解决方法。 方法一:递归解决。根据BST的特性。左边的小于根节点的值,右边的大于根节点的值。并且对于每一棵子树都是如此。所以我们可以直接递归的对左右子树的值与根节点的值进行比较。左子树的值小于当前根节点的值,将当前根节点的值作为最大值传 阅读全文
posted @ 2017-01-30 10:24 Kobe10 阅读(2946) 评论(1) 推荐(0) 编辑
摘要: 题目一:https://www.nowcoder.com/practice/166eaff8439d4cd898e3ba933fbc6358?tpId=46&tqId=29117&tPage=1&rp=1&ru=/ta/leetcode&qru=/ta/leetcode/question-ranki 阅读全文
posted @ 2017-01-29 15:50 Kobe10 阅读(5435) 评论(0) 推荐(0) 编辑
摘要: Largest Rectangle in Histogram Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area o 阅读全文
posted @ 2017-01-29 14:50 Kobe10 阅读(235) 评论(0) 推荐(0) 编辑
摘要: 题目:https://www.nowcoder.com/practice/fdbd05d647084fcf9be78444e231998b?tpId=46&tqId=29064&tPage=1&rp=1&ru=/ta/leetcode&qru=/ta/leetcode/question-rankin 阅读全文
posted @ 2017-01-29 13:53 Kobe10 阅读(291) 评论(0) 推荐(0) 编辑
摘要: https://www.nowcoder.com/practice/c5e8e84b62bb48398ec3c88153950fb5?tpId=46&tqId=29141&tPage=3&rp=3&ru=/ta/leetcode&qru=/ta/leetcode/question-ranking 题 阅读全文
posted @ 2017-01-26 15:20 Kobe10 阅读(272) 评论(0) 推荐(0) 编辑
摘要: 题目:https://www.nowcoder.com/practice/3b1abd8ba2e54452b6e18b31780b3635?tpId=46&tqId=29046&tPage=3&rp=3&ru=/ta/leetcode&qru=/ta/leetcode/question-rankin 阅读全文
posted @ 2017-01-26 10:13 Kobe10 阅读(1801) 评论(0) 推荐(0) 编辑
摘要: 原文地址:http://blog.csdn.net/qq_32400847/article/details/51336300 这篇帖子总结归纳很到位,值得学习。 阅读全文
posted @ 2017-01-25 10:26 Kobe10 阅读(604) 评论(0) 推荐(0) 编辑
摘要: 贪心算法 一、基本概念: 所谓贪心算法是指,在对问题求解时,总是做出在当前看来是最好的选择。也就是说,不从整体最优上加以考虑,他所做出的仅是在某种意义上的局部最优解。 贪心算法没有固定的算法框架,算法设计的关键是贪心策略的选择。必须注意的是,贪心算法不是对所有问题都能得到整体最优解,选择的贪心策略必 阅读全文
posted @ 2017-01-25 10:15 Kobe10 阅读(291) 评论(0) 推荐(0) 编辑
摘要: 题目:https://www.nowcoder.com/practice/4d135ddb2e8649ddb59ee7ac079aa882?tpId=46&tqId=29111&tPage=3&rp=3&ru=/ta/leetcode&qru=/ta/leetcode/question-rankin 阅读全文
posted @ 2017-01-24 11:07 Kobe10 阅读(2895) 评论(0) 推荐(0) 编辑
摘要: 题目:https://www.nowcoder.com/practice/9a9e74b71f944efab9992925f7f9a65e?tpId=46&tqId=29078&tPage=3&rp=3&ru=/ta/leetcode&qru=/ta/leetcode/question-rankin 阅读全文
posted @ 2017-01-24 10:44 Kobe10 阅读(2244) 评论(0) 推荐(0) 编辑
摘要: 题目:https://www.nowcoder.com/practice/e84e273b31e74427b2a977cbfe60eaf4?tpId=46&tqId=29130&tPage=3&rp=3&ru=/ta/leetcode&qru=/ta/leetcode/question-rankin 阅读全文
posted @ 2017-01-24 09:42 Kobe10 阅读(828) 评论(0) 推荐(0) 编辑
摘要: 问题一:https://www.nowcoder.com/practice/f0069cfcd42649e3b6b0c759fae8cde6?tpId=46&tqId=29148&tPage=3&rp=3&ru=/ta/leetcode&qru=/ta/leetcode/question-ranki 阅读全文
posted @ 2017-01-23 15:13 Kobe10 阅读(1107) 评论(0) 推荐(0) 编辑
摘要: 一、基本概念 在计算机科学中,分治法是一种很重要的算法。字面上的解释是“分而治之”,就是把一个复杂的问题分成两个或更多的相同或相似的子问题,再把子问题分成更小的子问题……直到最后子问题可以简单的直接求解,原问题的解即子问题的解的合并。这个技巧是很多高效算法的基础,如排序算法(快速排序,归并排序),傅 阅读全文
posted @ 2017-01-23 14:31 Kobe10 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 题目:https://www.nowcoder.com/practice/d8566e765c8142b78438c133822b5118?tpId=46&tqId=29071&tPage=3&rp=3&ru=/ta/leetcode&qru=/ta/leetcode/question-rankin 阅读全文
posted @ 2017-01-22 19:39 Kobe10 阅读(1834) 评论(0) 推荐(0) 编辑
摘要: 原题:https://www.nowcoder.com/practice/ed2923e49d3d495f8321aa46ade9f873?tpId=46&tqId=29065&tPage=3&rp=3&ru=/ta/leetcode&qru=/ta/leetcode/question-rankin 阅读全文
posted @ 2017-01-22 16:16 Kobe10 阅读(1586) 评论(0) 推荐(0) 编辑
摘要: 原题:https://www.nowcoder.com/practice/1b0b7f371eae4204bc4a7570c84c2de1?tpId=46&tqId=29077&tPage=3&rp=3&ru=/ta/leetcode&qru=/ta/leetcode/question-rankin 阅读全文
posted @ 2017-01-22 14:32 Kobe10 阅读(7033) 评论(0) 推荐(0) 编辑
摘要: 1.判断单链表是否有环 使用两个slow, fast指针从头开始扫描链表。指针slow 每次走1步,指针fast每次走2步。如果存在环,则指针slow、fast会相遇;如果不存在环,指针fast遇到NULL退出。 就是所谓的追击相遇问题: 2.求有环单链表的环长 在环上相遇后,记录第一次相遇点为Po 阅读全文
posted @ 2017-01-22 10:53 Kobe10 阅读(245) 评论(0) 推荐(0) 编辑