自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(16)
  • 收藏
  • 关注

原创 Linux查找文件夹下文件中字符串及替换字符串

一、grep:1、grep是Linux下搜索文件文本的工具,能使用正则表达式搜索文本,并把匹配的文本所在位置打印下来。2、使用格式:grep [OPTION]... PATTERN [FILE]...[OPTION]常用参数:-n或 --line-number 打印所在行数编号-r 或 --recursive 等同于 --directories...

2019-03-06 11:09:04 5226

原创 c++ sort函数总结

sort函数经常在算法题中被使用,这里对其用法进行总结:一、需要使用头文件#include<algorithm>和using namespace std;  二、语法:sort(begin,end,cmp),cmp参数可以省略,默认按升序排序。1)begin是要排序的数组的起始地址。  2)end是最后一位要排序的地址。 3)第三个参数是排序的方式,可以是从大到小也可是从小...

2018-11-13 10:06:11 691

原创 Leetcode 141. Linked List Cycle && 142. Linked List Cycle II

题目:141  Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?题目分析:判断一个链表是否存在环,并且时间复杂度为O(1),考虑用两个指针,p和q,p指针一次走一步,q指针一次走两步,若存在环,那么p指针进入环后,...

2018-09-05 10:27:01 156

原创 Leetcode 128. Longest Consecutive Sequence

题目:Given an unsorted array of integers, find the length of the longest consecutive elements sequence.Your algorithm should run in O(n) complexity.Example:Input: [100, 4, 200, 1, 3, 2]Output: 4...

2018-08-28 13:59:26 106

原创 Leetcode 123.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 day i.Design an algorithm to find the maximum profit. You may complete at most two transactions.Note: You may not e...

2018-08-23 10:56:36 172

原创 Leetcode 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 (i.e., buy on...

2018-08-21 10:50:43 97

原创 Leetcode 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 (i.e., buy one and sell one share of the stock),...

2018-08-21 10:29:49 104

原创 Leetcode149. Max Points on a Line

题目:Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.Example 1:Input: [[1,1],[2,2],[3,3]]Output: 3Explanation:^||        o|     o|  o  +...

2018-08-16 15:18:22 148

原创 Leetcode97. Interleaving String

题目:Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2.Example 1:Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbcbcac"Output: trueExample 2:Input: s1 = "aabcc", s2 ...

2018-08-14 11:09:16 93

原创 Leetcode96. Unique Binary Search Trees

题目:Given n, how many structurally unique BST's (binary search trees) that store values 1 ... n?Example:Input: 3Output: 5Explanation:Given n = 3, there are a total of 5 unique BST's: 1 ...

2018-08-13 15:08:38 103

原创 Leetcode 95. Unique Binary Search Trees II

题目:Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1 ... n.Example:Input: 3Output:[  [1,null,3,2],  [3,2,null,1],  [3,1,null,null,2],  [...

2018-08-13 10:32:28 112

原创 Leetcode89. Gray Code

题目:The gray code is a binary numeral system where two successive values differ in only one bit.Given a non-negative integer n representing the total number of bits in the code, print the sequence

2017-08-13 11:10:46 267

原创 C++vector常见用法总结

在用c++编程时,经常会遇到无法确定元素个数或者可变大小的数组,这时使用灵活的vector容器十分方便,下面对经常使用的用法进行总结。一、头文件:#include,要接using namespace std;使命名空间std内定义的所有标识符都有效。二、声明及初始化:vectora;//声明一个T型容器avector a(n);//声明一个初始大小为n的容器 vect

2017-08-03 14:46:36 294

原创 Leetcode87. Scramble String

Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively.Given two strings s1 and s2 of the same length, determine if s2 is a scrambled

2017-07-31 16:16:09 181

原创 Leetcode85. Maximal Rectangle.

Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.题目:在二维矩阵中找到最大矩形。    直接看这道题目有些困难,但和Leetcode84求柱形图的最大矩形面积结合起来就简单多了。与84题的区别在于柱形图的底

2017-07-29 11:23:03 205

原创 Leetcode84. 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 of largest rectangle in the histogram.题目:给定一个柱状图,找到其中最大的矩阵。    要想找

2017-07-28 11:05:13 242

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除