摘要: https://leetcode.com/problems/find-the-difference/ public class Solution { public char findTheDifference(String s, String t) { char[] sch = s.toCharArray(); char[] tch = t.toChar... 阅读全文
posted @ 2016-08-30 17:13 blcblc 阅读(192) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/longest-absolute-file-path/ public class Solution { public int lengthLongestPath(String input) { Stack stk = new Stack(); int left = 0; int ... 阅读全文
posted @ 2016-08-30 01:05 blcblc 阅读(207) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/first-unique-character-in-a-string/ public class Solution { public int firstUniqChar(String s) { int[] index = new int[26]; for (int i=0; i 0) { ... 阅读全文
posted @ 2016-08-29 11:59 blcblc 阅读(263) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/lexicographical-numbers/ public class Solution { public List lexicalOrder(int n) { List ret = new ArrayList(); int cur = 1; ret.add(cur); ... 阅读全文
posted @ 2016-08-29 00:23 blcblc 阅读(195) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/mini-parser/ /** * // This is the interface that allows for creating nested lists. * // You should not implement it, or speculate about its implementation * public i... 阅读全文
posted @ 2016-08-28 23:31 blcblc 阅读(350) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/shuffle-an-array/ public class Solution { int [] origNums; int [] shufNums; java.util.Random rd; public Solution(int[] nums) { origNums = nums... 阅读全文
posted @ 2016-08-28 16:05 blcblc 阅读(171) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/ransom-note/ public class Solution { public boolean canConstruct(String ransomNote, String magazine) { char[] chRan = ransomNote.toCharArray(); char... 阅读全文
posted @ 2016-08-28 12:10 blcblc 阅读(174) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/linked-list-random-node/ // Using Reservoir sampling algorithm // https://discuss.leetcode.com/topic/53812/using-reservoir-sampling-o-1-space-o-n-time-complexity-c/2 /... 阅读全文
posted @ 2016-08-28 11:24 blcblc 阅读(236) 评论(0) 推荐(0)
摘要: https://leetcode.com/problems/insert-delete-getrandom-o1-duplicates-allowed/ public class RandomizedCollection { ArrayList nums; HashMap> locs; java.util.Random rand; /** Initialize... 阅读全文
posted @ 2016-08-27 23:58 blcblc 阅读(375) 评论(0) 推荐(0)
摘要: <!--?xml version="1.0" encoding="UTF-8" standalone="no"?--> http://www.cnblogs.com/lovebread/archive/2009/11/24/1609936.html 阅读全文
posted @ 2016-08-22 11:03 blcblc 阅读(334) 评论(0) 推荐(0)