Two Pointers
文章平均质量分 52
liujunlovecs
这个作者很懒,什么都没留下…
展开
-
Leetcode#11||Container With Most Water
public class Solution { public int maxArea(int[] height) { if (height == null || height.length < 2) { return 0; } int left = 0; int right = hei原创 2015-08-11 15:07:22 · 208 阅读 · 0 评论 -
Leetcode#75||Sort Colors
public class Solution { public void sortColors(int[] nums) { if (nums == null || nums.length < 2) { return; } int length = nums.length;原创 2015-08-19 14:03:30 · 305 阅读 · 0 评论 -
Leetcode#61||Rotate List
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public class Solution { public ListNode rota原创 2015-08-18 11:08:55 · 286 阅读 · 0 评论 -
Leetcode#42||Trapping Rain Water
public class Solution { public int trap(int[] height) { if (height == null || height.length < 3) { return 0; } int result = 0; int maxHeightInd原创 2015-08-15 09:09:25 · 207 阅读 · 0 评论 -
Leetcode#31||Next Permutation
public class Solution { public void nextPermutation(int[] nums) { if (nums == null || nums.length <= 1) { return; } int left = 0; for (int i =原创 2015-08-14 16:11:44 · 208 阅读 · 0 评论 -
Leetcode#30||Substring with Concatenation of All Words
public class Solution { public List findSubstring(String s, String[] words) { List result = new ArrayList(); if (s == null || s.length() == 0 || words.length == 0) {原创 2015-08-13 10:20:27 · 192 阅读 · 0 评论 -
Leetcode#28||Implement strStr()
public class Solution { public int strStr(String haystack, String needle) { if (haystack == null || haystack.length() < needle.length()) { return -1; }原创 2015-08-13 07:25:07 · 240 阅读 · 0 评论 -
Leetcode#26||Remove Duplicates from Sorted Array
public class Solution { public int removeDuplicates(int[] nums) { if (nums.length <= 1) { return nums.length; } int cnt = 0; for (int原创 2015-08-12 17:13:12 · 197 阅读 · 0 评论 -
Leetcode#18||4 Sum
public class Solution { public List> fourSum(int[] nums, int target) { List> result = new ArrayList>(); if (nums == null || nums.length < 3) { return result;原创 2015-08-12 12:09:00 · 192 阅读 · 0 评论 -
Leetcode#27||Remove Element
public class Solution { public int removeElement(int[] nums, int val) { if (nums == null || nums.length == 0) { return 0; } int cnt = 0;原创 2015-08-12 17:18:22 · 209 阅读 · 0 评论 -
Leetcode#19||Remove Nth Node From End of List
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public class Solution { public ListNode remo原创 2015-08-12 12:17:16 · 216 阅读 · 0 评论 -
Leetcode#15||3 Sum
public class Solution { public List> threeSum(int[] nums) { List> result = new ArrayList>(); if (nums == null || nums.length < 3) { return result; }原创 2015-08-12 10:53:55 · 199 阅读 · 0 评论 -
Leetcode#16||3 Sum Closest
public class Solution { public int threeSumClosest(int[] nums, int target) { if (nums == null || nums.length < 3) { return -1; } int min = Integer.MAX_原创 2015-08-12 11:01:51 · 210 阅读 · 0 评论 -
Leetcode#3||Longest Substring Without Repeating Characters
Using HashSet.public class Solution { public int lengthOfLongestSubstring(String s) { if (s == null || s.length() == 0) { return 0; } Set set = new H原创 2015-08-11 10:07:16 · 236 阅读 · 0 评论 -
Leetcode#76||Minimum Window Substring
public class Solution { public String minWindow(String s, String t) { String result = ""; if (s == null || t == null || s.length() < t.length()) { return resul原创 2015-08-19 16:51:15 · 321 阅读 · 0 评论