摘要: Given a string, find the length of the longest substring without repeating characters. Examples: Given "abcabcbb", the answer is "abc", which the leng 阅读全文
posted @ 2018-07-05 03:47 小小Cv 阅读(114) 评论(0) 推荐(0) 编辑
摘要: Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target valu 阅读全文
posted @ 2018-06-26 22:37 小小Cv 阅读(96) 评论(0) 推荐(0) 编辑
摘要: 假设你对KMP算法有了解但感到困惑,本文不解释KMP算法的定义。 之前查找资料的时候看到长篇大论的,所以看都不想看,结果自己想表达出来时。。。也变得长篇大论了 详细说一下KMP算法,刚看到的时候一头雾水,想不明白lps[]这个数组的作用,以及实现。 在说明lps[]之前先说明一下最长的相同的前缀后缀 阅读全文
posted @ 2018-06-23 20:10 小小Cv 阅读(241) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution { 2 public: 3 int removeDuplicates(vector& nums) { 4 if(nums.empty()) 5 return 0; 6 int i = 0; 7 for(int j = 1; j < nums.size(); j++) ... 阅读全文
posted @ 2018-06-21 19:53 小小Cv 阅读(100) 评论(0) 推荐(0) 编辑
摘要: Given a matrix of M x N elements (M rows, N columns), return all elements of the matrix in diagonal order as shown in the below image. 阅读全文
posted @ 2018-06-19 10:35 小小Cv 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 快速排序是比较常用的到的一个算法,也使用了分治思想。 快排主要找到一个分界点partition,使得[left,partition-1]的所有元素小于或等于[partition],使得[partition+1,right]的所有元素大于[partition] 此时已经算排好一个位置(partitio 阅读全文
posted @ 2018-06-14 19:29 小小Cv 阅读(138) 评论(0) 推荐(0) 编辑
摘要: = = 因为用的是数组实现,所以在size比较大的时候会内存溢出 阅读全文
posted @ 2018-06-13 22:49 小小Cv 阅读(125) 评论(0) 推荐(0) 编辑
摘要: 1 struct A 2 { 3 int maxright; // 记录右边最大子数组的下标 4 int maxleft; // 记录左边最大子数组的下标 5 int sum; // 记录数组下标maxleft--maxright的元素和 6 }; 7 8 void Solution... 阅读全文
posted @ 2018-06-12 23:50 小小Cv 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 1 #include 2 3 struct input_iterator_tag {}; 4 struct output_iterator_tag {}; 5 struct forward_iterator_tag : public input_iterator_tag {}; 6 struct bidirectional_iterator_tag : public ... 阅读全文
posted @ 2018-06-12 18:08 小小Cv 阅读(167) 评论(0) 推荐(0) 编辑
摘要: 分治模式在每层递归时都有三个步骤: 一:分解原问题为若干子问题,这些子问题都是原问题的规模较小的实例 二:解决这些子问题,递归地求解各个子问题。 三:合并这些子问题的解,使成为原问题的解 比如上述算法,将对一个数组排序的问题不断切分为更小的排序问题,直到最后(left<right),此时所有实例都是 阅读全文
posted @ 2018-06-12 18:02 小小Cv 阅读(230) 评论(0) 推荐(0) 编辑