自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(368)
  • 资源 (3)
  • 收藏
  • 关注

原创 let 72 Edit Distance

Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:

2018-01-15 22:33:31 122

原创 let 71 Simplify Path

Given an absolute path for a file (Unix-style), simplify it.For example,path = "/home/", => "/home"path = "/a/./b/../../c/", => "/c"click to show corner cases.Corner Cases:Did you consider the

2018-01-15 21:21:21 106

原创 let 56 Merge Interval

主题思想: 首先,这类题,一般都需要排序,否则时间复杂度太高,而且实现起来很复杂,如果能够排序,则问题得以化简, 需要合并的肯定是具有重合,按起始点排序后,利用栈的概念,保证了要处理的元素和栈顶元素只有两种关系,能合并,和不能合并 如果能合并,就合并,不能合并新加到列表里,接下来的interval 肯定不会和以前的,接下来接着和栈顶进行比较。技术点是: 实现Comparator

2018-01-13 21:51:31 225

原创 let 55 Jump Game

主题思想: 这个和Jump GameII 是类似的题做题思路就是贪心算法, 首先获取最大可以走到的下标,然后依次走一步,记录在走到上一次计算到的最大下标位置时出现的最大值,当走到上一次计算的最大下标时,更新下一步可以到达的最大下标,如果下一步可以到达的下标大于数组最后一个元素下标,则可以到达。如果等于当前下标,说明止步不前,则无法到达数组最后一个元素。AC代码:class Sol

2018-01-12 21:33:45 111

原创 let 52 N-Queens II

主题思想: 回溯,搜索题。 这次考察回溯如何返回值。AC 代码:class Solution { public int totalNQueens(int n) { return dfs(0,n,new ArrayList ()); } public int dfs(int step,int n,List record){ if

2018-01-12 20:57:39 125

原创 let 51 N-Queens

主题思想: 这是一道搜索题, 典型的回溯算法思路。 当搜索时,通常满足条件,需要改变某种状态。一种情况处理完后,应该把改变的状态再改回来,这就是回溯的核心。 典型的深度搜索。 具体到这道题, 可以对存储空间优化,因为搜索时可以一行一行搜索,即先寻找第一行合适的位置,再寻找第二行,这样可以用一个List 记录每一行的位置,list中添加的下标就是行号,存储的值是对应的列值。具体代码:cl

2018-01-12 20:56:18 113

原创 let 50 Pow(x,n)

主题思想: n 的取值范围 n0快速幂算法public double quickPow(double x,int n){ if(n==0) return 1.0000; double ans=1.0; while(n!=0){ if(n%2!=0){ ans=ans*x;

2018-01-10 22:31:31 121

原创 let 49 Group Anagrams

Given an array of strings, group anagrams together.For example, given: ["eat", "tea", "tan", "ate", "nat", "bat"], Return:[ ["ate", "eat","tea"], ["nat","tan"], ["bat"]]主题思想: 这个刚开始第一眼思

2018-01-10 22:00:06 127

原创 let 46 Permutations

Given a collection of distinct numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[ [1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]]主

2018-01-10 16:15:11 133

原创 let 45 Jump Game II

主题思想: 这是一道贪心算法, 要尽可能地跳的远,首先 明确什么时候更新步数, 根据当前i 能知道从i 能走到的最大步数 ith-long,在没走到ith-long达到的最大步数之前,记录中间步骤所能更新的最大值,当i达到ith-long 是更新下一步最大值为中间的最大值,并更新步数。class Solution { public int jump(int[] nums) {

2018-01-10 15:13:27 164

原创 let44 Wildcard Matching

'?' Matches any single character.'*' Matches any sequence of characters (including the empty sequence).The matching should cover the entire input string (not partial).The function prototype shoul

2018-01-09 21:58:17 209

原创 let43 Multiply String

主题思想: 大数乘法, 这里写一种大数乘法的通用模板,整体思路是: 利用数组,一个int型数组表示长度为4的子串, 为什么是4呢? 因为int 型 21亿,1亿=10^9, 长度为4最大值9999,两个值相乘大体思路如下,把字符串,按每四位截取,并转换成int 存储在数组里运算时,对int数组进行运算,输出结果需要注意,去除前导0, 对于中间值为0的情况,要输出4个0.代码:

2018-01-08 22:48:08 189

原创 let41 41. First Missing Positive

Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant space

2018-01-08 15:47:50 114

原创 let 39 Combination Sum

Given a set of candidate numbers (C) (without duplicates) and a target number (T), find all unique combinations in C where the candidate numbers sums to T.The same repeated number may be chosen from

2018-01-06 22:23:55 96

原创 let 35 Search Insert Position

主题思想: 这道题和33,34 本质是一样的,都是考察二分查找,只不过这一道题不是找到返回下标,找不到返回-1,而是返回大于目标值的最小值下标,也可以说是返回target的排名,即比target小的数有几个。和二分查找仅仅是返回值不同这里返回low就可以了。“` class Solution { public int searchInsert(int[] nums, int

2018-01-06 16:00:00 97

原创 let 34 Search for a Range

Given an array of integers sorted in ascending order, find the starting and ending position of a given target value.Your algorithm's runtime complexity must be in the order of O(log n).If the targ

2018-01-06 15:49:14 86

原创 let 33 Search in Rotated Sorted Array

Suppose an array sorted in ascending order 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 value to search. If found in t

2018-01-06 15:32:55 92

原创 32. Longest Valid Parentheses

Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.For "(()", the longest valid parentheses substring is "()", which

2018-01-06 00:17:23 107

原创 let 31 Next Permutation

参考博客: https://www.cnblogs.com/eudiwffe/p/6260699.html 主题思想: 构造下一个排列的思路如下:从后往前找,找到第一个降序对(从后往前降序)出现的位置,比如 1,2,5,4,3 找到第一个出现a[i]class Solution { public void nextPermutation(int[] nums) {

2018-01-05 17:32:00 122

原创 let 30 Substring with Concatenation of All Words

You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of each word in words exactly once and wi

2018-01-05 15:21:44 116

原创 let29 Divide Two Integers

Divide two integers without using multiplication, division and mod operator.If it is overflow, return MAX_INT. 主题思想: 不用乘除取模做除法运算, 首先肯定用加减法, 但是由于直接加减速度太慢,然后联想到,对数优化,以2次幂的方式进行加减,这样速度优化log 最后是处理各种边界问题,

2018-01-03 22:11:58 129

原创 let 28 Implement strStr()

Implement strStr().Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.Example 1:Input: haystack = "hello", needle = "ll"Output: 2Example 2:Input: h

2018-01-03 17:12:51 95

原创 let 27 Remove Elements

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 by modifying the input array in-place w

2018-01-03 16:33:25 89

原创 let 26 Remove Duplicates from Sorted Array

主题思想: 排序去重,只需要,记录当前有序的位置,遇到新元素放到当前有序的下一个位置就可以了。class Solution { public int removeDuplicates(int[] nums) { if(nums==null)return 0; int pre=0; for(int i=1;i<nums.length;i++){

2018-01-03 16:11:08 92

原创 let 25 Reverse Nodes in k-Group

Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the length of the linked list. If the number of nod

2018-01-03 15:31:35 107

原创 let24 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 space. You may not

2017-12-29 16:16:55 100

原创 IDEA 常用快捷键总结---持续更新

查看一个类中所有方法的快捷键,(类似于eclipse ctrl +o) ctrl+F12查看一个类的架构的快捷键,比如查看一个类继承那个类,实现哪个接口, ctrl+H上移、下移一行代码的快捷键(类似eclipse ctrl-alt-方向键) ctrl+shift+方向键

2017-12-27 16:47:04 198

转载 storm IRichBolt 和IBasicBolt区别

转载自:http://blog.csdn.net/ch717828/article/details/52561904主题内容: 总结如下: 1.如果使用IRichBolt emit()后需要执行手动调用ack方法2. 如果使用IBasicBolt 不需要手动调用ack方法因为IRichBolt 用的是OutputCollector里面有两个emit方法//the next compo

2017-12-27 16:01:33 460

原创 let23 merge k sorted lists

主题思想: 此题是合并2个有序链表的升级版,1个解决思路就是,分治法: 把k个链表,分割成若干个2个链表的合并,然后再合并最后2个链表,这样就把一个新的看似复杂的问题,分解为小问题,易于解决的问题。/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode

2017-12-26 22:24:03 112

原创 let21 merge two linked list

合并两个有序链表 主题思想: 因为是有序的,这题有两种解法,递归、循环。递归解法,代码比较简洁 public ListNode mergeTwoLists(ListNode l1, ListNode l2) { if(l1==null) return l2; if(l2==null) return l1; if(l1.val<l2.val){ l1.next

2017-12-26 22:13:15 136

原创 let 22 generate parentheses

主题思想: 此题是一道搜索题,后者是一道回溯题,解法有dfs和递归一种解法:class Solution { public List<String> generateParenthesis(int n) { List<String> list=new ArrayList<>(); backtrack(list,"",0,0,n); return

2017-12-21 22:04:21 119

原创 剑指offer 之 Remove the Nth Node from the end of list

主题思想: 题目大意是: 删除从链表尾部开始向前数的第N个数,,第一个是链表尾部Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the linked list becomes 1->2->3->5.这道题考察的是单向链表只能往后遍历的特点。解决思路: 用两个指针,

2017-12-21 11:39:13 110

原创 一些测试工具ab,jmeter

apache 旗下:ab 用于对web服务器 进行压力测试Jmeter 可以进行接口性能压力测试。

2017-12-20 16:25:40 539

原创 java 利用BufferedWriter 读写文件需要flush 缓存

BufferedWriter 从名字上来看就是利用Buffer缓存的, 因此写完数据之后要就上buffer.flush() //否则,则会出现数据没有完全写进去//最后buffer.close()

2017-12-20 15:00:34 3914 7

原创 ubuntu下 python 好用的IDE

首先python IDE 有名的有以下几个: pyCharm 、 eclipse python 插件, sumlime 配置各种插件但是这些都太重量级了,太耗费资源了,也可以说启动太慢了ubuntu 下, 如果直接用vim 则没有提示,不太友好spyder sudo apt-get install spyder即可,有代码提示,以及函数用法自带文档,非常方便好用

2017-12-20 14:57:38 20095 2

原创 Mongo DB java 起步操作,连接数据库,查询语句

首先, 下载mongo-java_driver maven 依赖如下 <dependency> <groupId>org.mongodb</groupId> <artifactId>mongo-java-driver</artifactId> <version>3.5.0</version> </dependency>导入相关类。import com.mo

2017-12-20 14:50:54 354

原创 mongodb 免费可视化关系工具 Robo 3T

Robo 3T 是一款叫mongodb 可视化工具, 是一个免费版本,还有个付费版本叫Studio 3T 官网 https://robomongo.org/解压后直接bin启动相应脚本就可以了,非常好用

2017-12-14 16:14:51 11715 3

原创 storm 1.1.1 起步总结,摸索中走过的坑,如何避免输出无关信息

首先弄清楚一个问题, IDEA IDE创建目录的时候会有一个resources目录,src/main/resources 之后所有的配置文件都应位于src/main/resources 目录下,代码才能默认找到。如何避免输出系统信息在`src/main/resources` 新建log4j2.xml<?xml version="1.0" encoding="UTF-8"?><Confi

2017-12-11 12:07:00 723

原创 maven 阿里云mirror

nexus-aliyun central Nexus aliyun http://maven.aliyun.com/nexus/content/repositories/central

2017-12-07 15:59:16 330

原创 HashMap,Hashtable,SynchronizedHashMap,ConcurrentHashMap

java 的HashMap总结HashMap与HashTable: HashMap key value 都可以是null,Hashtable 不可以, HashMap 线程不安全,Hashtable 线程安全SynchronizedHashMap, ConcurrentHashMapSynchronizedHashMap是采用全部加锁,相当于包装了一层,内部加完锁再调用hashmap,返回的

2017-12-07 14:27:58 800

学习vim 编辑器 第7版

学习vim 编辑器,最新版,vim学习必看。包含了vim的各种使用技巧。

2017-11-14

深入浅出iphone开发中文版

head first iphone programming 中文版

2016-09-26

网络水晶头接法

网络水晶头的接法,再也不用发愁水晶头不会接了

2014-07-08

空空如也

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

TA关注的人

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