2016年5月17日

String, StringBuilder, StringBuffer问题

摘要: 1. 区别 String为字符串常量,而StringBuilder和StringBuffer都是字符串变量,其中StringBuilder线程非安全,StringBuffer线程安全。 每次对 String 类型进行改变的时候其实都等同于生成了一个新的 String 对象,然后将指针指向新的 Str 阅读全文

posted @ 2016-05-17 17:30 ShinningWu 阅读(142) 评论(0) 推荐(0) 编辑

2016年5月14日

Letter Combinations of a Phone Number:深度优先和广度优先两种解法

摘要: Letter Combinations of a Phone Number Given a digit string, return all possible letter combinations that the number could represent. A mapping of digi 阅读全文

posted @ 2016-05-14 17:05 ShinningWu 阅读(225) 评论(0) 推荐(0) 编辑

Combination Sum系列问题

摘要: 主要使用方法是backtracking。 Combination Sum Given a set of candidate numbers (C) and a target number (T), find all unique combinations in C where the candida 阅读全文

posted @ 2016-05-14 14:32 ShinningWu 阅读(168) 评论(0) 推荐(0) 编辑

2016年3月24日

Best Time to Buy and Sell Stock系列

摘要: I题 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 transact 阅读全文

posted @ 2016-03-24 11:57 ShinningWu 阅读(415) 评论(0) 推荐(0) 编辑

2016年3月23日

Different Ways to Add Parentheses

摘要: 题目如下: Given a string of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operato 阅读全文

posted @ 2016-03-23 16:09 ShinningWu 阅读(167) 评论(0) 推荐(0) 编辑

2016年3月8日

ksum问题

摘要: 2sum: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would h 阅读全文

posted @ 2016-03-08 17:06 ShinningWu 阅读(201) 评论(0) 推荐(0) 编辑

2015年12月24日

backtracking问题

摘要: backtracking最基础的问题是Subsets,即给定一个数组,要求返回其所有子集。Given a set of distinct integers,nums, return all possible subsets.Note:Elements in a subset must be in n... 阅读全文

posted @ 2015-12-24 15:27 ShinningWu 阅读(168) 评论(0) 推荐(0) 编辑

2015年11月24日

位运算问题

摘要: n & (n - 1)的作用:把n中为1的最低位变为0.Power of TwoGiven an integer, write a function to determine if it is a power of two.解法:2的次幂的特征是有且仅有一位为1,其余为均为零。故可利用判断n & (... 阅读全文

posted @ 2015-11-24 12:10 ShinningWu 阅读(142) 评论(0) 推荐(0) 编辑

2015年11月23日

number问题

摘要: Missing NumberGiven an array containingndistinct numbers taken from0, 1, 2, ..., n, find the one that is missing from the array.For example,Givennums=... 阅读全文

posted @ 2015-11-23 20:48 ShinningWu 阅读(187) 评论(0) 推荐(0) 编辑

2015年11月19日

BinarySearch的一些注意事项

摘要: BinarySearch原理比较简单,不过在处理实际问题的过程中需要注意几个小问题:1. 找出有序数组中第一个为某特定值的数,以及没找到则返回-12. 找出有序数组中最后一个为某特定值的数,以及没找到则返回-1 阅读全文

posted @ 2015-11-19 10:54 ShinningWu 阅读(165) 评论(0) 推荐(0) 编辑

导航