刷题心得
_猜猜猜
这个作者很懒,什么都没留下…
展开
-
关于一道题目解法
题目: 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 have exactly one solution.Example:Given nums =原创 2016-04-12 12:13:09 · 1546 阅读 · 1 评论 -
牛客网刷题笔记1
题目:For the following Java or C# code(3 Points),What will my Array3[2][2] returns? int [][] myArray3 = new int[3][]{ new int[3]{5,6,2}, new int[5]{6,9,7,8,3}, new int[2]{3,2}}; 答案是:overflow 原因:首先原创 2016-04-12 21:39:35 · 900 阅读 · 0 评论 -
三色旗问题中的快排应用
今天在看三色旗问题的时候觉得这个问题用的就是快排思想,然后查了一下,Letcode上正好有这样类似的一道题目下面是Letcod上面的这个问题的题目75.Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the原创 2016-05-17 17:37:07 · 876 阅读 · 0 评论 -
字符串问题(一)
判断两个字符串是不是互为变形词 str1 = “123”,str2 = “231”,返回true。 str1 = “123”,str2 = “2331”,返回false。 public boolean isDeformation1(String str1, String str2){ if(str1 == null || str2 == null || str1.lengt原创 2017-02-06 14:28:37 · 237 阅读 · 0 评论 -
字符串问题(二)
字符串中的数字求和 str = “A1CD2E32”,返回 36。 str = “A-1B–2C–D6E”,返回7。 public static int numSum(String str){ if(str == null){ return 0; } char[] charArr = str.toCharArray()原创 2017-02-06 15:24:35 · 248 阅读 · 0 评论 -
字符串问题(三)
去掉字符串中连续出现K个0的子串 public static String remove(String str, int k){ if(str == null || k < 1){ return str; } char[] cc = str.toCharArray(); int count = 0;原创 2017-02-06 16:11:22 · 223 阅读 · 0 评论 -
字符串问题(四)
判断两个词是否为旋转词 public boolean isRotation(String a, String b){ if(a == null || b == null || a.length() != b.length()){ return false; } String str = b.concat(b);原创 2017-02-06 16:13:47 · 180 阅读 · 0 评论 -
栈和队列(一)
找出最小值public class sAD01 { private Stack<Integer> Data; private Stack<Integer> Min; public sAD01(){ this.Data = new Stack<Integer>(); this.Min = new Stack<Integer>(); }原创 2017-02-20 15:01:09 · 220 阅读 · 0 评论 -
栈和队列(二)
由两个栈实现队列import java.util.Stack;public class sAD02 { public Stack<Integer> stackPush; public Stack<Integer> stackPop; public sAD02(){ stackPush = new Stack<Integer>(); stackPop原创 2017-02-20 15:02:23 · 234 阅读 · 0 评论