摘要:
public class Solution { public String countAndSay(int n) { if (n == 1) { return "1"; } String str = "1"; for... 阅读全文
posted @ 2015-12-01 16:11
Weizheng_Love_Coding
阅读(125)
评论(0)
推荐(0)
摘要:
public class Solution { public String longestCommonPrefix(String[] strs) { if (strs.length == 0) { return ""; } int... 阅读全文
posted @ 2015-12-01 15:55
Weizheng_Love_Coding
阅读(123)
评论(0)
推荐(0)
摘要:
public class Solution { public boolean containsNearbyDuplicate(int[] nums, int k) { HashMap map = new HashMap(); for (int i = 0; i < ... 阅读全文
posted @ 2015-12-01 15:48
Weizheng_Love_Coding
阅读(128)
评论(0)
推荐(0)
摘要:
public class Solution { public ListNode removeNthFromEnd(ListNode head, int n) { ListNode dummy = new ListNode(0); dummy.next = head;... 阅读全文
posted @ 2015-12-01 15:35
Weizheng_Love_Coding
阅读(100)
评论(0)
推荐(0)
摘要:
public class Solution { boolean result = true; public boolean isBalanced(TreeNode root) { helper(root); return result; } pub... 阅读全文
posted @ 2015-12-01 15:28
Weizheng_Love_Coding
阅读(106)
评论(0)
推荐(0)
摘要:
public class Solution { public int minDepth(TreeNode root) { if (root == null) { return 0; } Queue queue = new Link... 阅读全文
posted @ 2015-12-01 15:25
Weizheng_Love_Coding
阅读(126)
评论(0)
推荐(0)
摘要:
public class Solution { public boolean canAttendMeetings(Interval[] intervals) { Arrays.sort(intervals, new Comparator() { public... 阅读全文
posted @ 2015-12-01 15:06
Weizheng_Love_Coding
阅读(128)
评论(0)
推荐(0)
摘要:
public class Solution { public boolean isAnagram(String s, String t) { char[] first = s.toCharArray(); Arrays.sort(first); cha... 阅读全文
posted @ 2015-12-01 15:03
Weizheng_Love_Coding
阅读(119)
评论(0)
推荐(0)
摘要:
public class Solution { public int titleToNumber(String s) { int result = 0; int tmp = 1; for (int i = s.length() - 1; i >= 0;... 阅读全文
posted @ 2015-12-01 15:01
Weizheng_Love_Coding
阅读(105)
评论(0)
推荐(0)
摘要:
public class Solution { public int longestConsecutive(int[] nums) { HashSet set = new HashSet(); for (int num : nums) { se... 阅读全文
posted @ 2015-12-01 10:02
Weizheng_Love_Coding
阅读(107)
评论(0)
推荐(0)
摘要:
public class Solution { private int result = 0; public int longestConsecutive(TreeNode root) { if (root == null) { return 0; ... 阅读全文
posted @ 2015-12-01 09:54
Weizheng_Love_Coding
阅读(139)
评论(0)
推荐(0)
摘要:
public class Solution { public int lengthOfLIS(int[] nums) { int length = nums.length; List record = new ArrayList(); for (int... 阅读全文
posted @ 2015-12-01 09:30
Weizheng_Love_Coding
阅读(123)
评论(0)
推荐(0)
摘要:
public class Solution { public boolean wordPatternMatch(String pattern, String str) { return helper(pattern, str, new HashMap(), new HashMap... 阅读全文
posted @ 2015-12-01 09:01
Weizheng_Love_Coding
阅读(141)
评论(0)
推荐(0)
摘要:
用的dfs,但是感觉这个方法应该不是最优的,否则这个题目不应该是hardpublic class Solution { int up = Integer.MAX_VALUE; int low = Integer.MIN_VALUE; int left = Integer.MAX_V... 阅读全文
posted @ 2015-12-01 08:08
Weizheng_Love_Coding
阅读(145)
评论(0)
推荐(0)
摘要:
相当tricky的一道题目,我怀疑在面试的时候有人能在45分钟想出来,我参考了一下https://leetcode.com/discuss/72215/java-dp-solution-with-detailed-explanation-o-n-3这个人的思路。public class Soluti... 阅读全文
posted @ 2015-12-01 07:07
Weizheng_Love_Coding
阅读(698)
评论(0)
推荐(0)
摘要:
public class Solution { public int minCostII(int[][] costs) { int n = costs.length; if (n == 0) { return 0; } ... 阅读全文
posted @ 2015-12-01 07:04
Weizheng_Love_Coding
阅读(141)
评论(0)
推荐(0)
摘要:
public class Solution { public ListNode removeElements(ListNode head, int val) { ListNode dummy = new ListNode(0); dummy.next = head;... 阅读全文
posted @ 2015-12-01 05:12
Weizheng_Love_Coding
阅读(134)
评论(0)
推荐(0)
摘要:
public class Solution { public void connect(TreeLinkNode root) { if (root == null) { return; } Queue queue = new Li... 阅读全文
posted @ 2015-12-01 03:18
Weizheng_Love_Coding
阅读(135)
评论(0)
推荐(0)
摘要:
//DFS,没有剪枝public class Solution { List> result = new ArrayList>(); public List> combinationSum3(int k, int n) { helper(k, n, 0, new Array... 阅读全文
posted @ 2015-12-01 02:02
Weizheng_Love_Coding
阅读(137)
评论(0)
推荐(0)

浙公网安备 33010602011771号