- 博客(7)
- 资源 (3)
- 收藏
- 关注
转载 Leetcode 20. Valid Parentheses - javascript
/** * @param {string} s * @return {boolean} */var isValid = function(s) { var stack = []; for(var i = 0; i < s.length; i++){ var c = s.charAt(i); if(c == "(" ||
2016-07-22 07:39:14 402
转载 Leetcode 6. ZigZag Conversion
public String convert(String s, int n) { //corner case if(s == null || "".equals(s) || n <= 0){ return ""; } if(n == 1){ return s;
2016-07-21 09:50:29 171
转载 Leetcode 7. Reverse Integer
public int reverse(int x) { boolean flag = true; long result = 0; if(x < 0){ flag = false; } x = Math.abs(x); while(x > 0
2016-07-21 08:51:22 180
转载 Leetcode 8. String to Integer (atoi)
public int myAtoi(String str) { if(str == null || str.length() == 0){ return 0; } //space, + -, non num, out of bound boolean fla
2016-07-21 08:50:30 186
转载 Leetcode 75. Sort Colors
public void sortColors(int[] nums) { //conor case if(nums == null || nums.length < 1){ return; } //two pointers int slow = 0; int f
2016-07-20 08:48:21 190
转载 Leetcode 33, 81 Search in Rotated Sorted Array I, II
public int search(int [] A,int target){ if(A==null||A.length==0) return -1; int low = 0; int high = A.length-1; while(low <= high){ int mid = (
2016-07-20 03:06:44 248
原创 Leetcode 34, Search for a Range
public int[] searchRange(int[] nums, int target) { if(nums == null || nums.length == 0){ return null; } int[] result = {-1, -1}; //binary search, 2 times
2016-07-13 14:27:23 189
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人