摘要:
/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public... 阅读全文
摘要:
public class Solution { public int numDecodings(String s) { int len = s.length(); if(len == 0) return 0; int[] counts = new in... 阅读全文
摘要:
We can easily use hashset to solve this problem, based on the previous Subset problem.Code:public class Solution { public List> subsetsWithDup(int[... 阅读全文
摘要:
We can find the regular pattern in gray code, which is:the first of the combinations of n-digit gray code is exactly the combinations of (n-1)-digit g... 阅读全文
摘要:
At the first sight of the problem, I misunderstood it as sort the former part of the list and then keep the original order of those nodes in the large... 阅读全文
摘要:
First we need to get the head node, use a boolean value to mark whether we find a new head or not. When we traverse the linked list,if(cur.val != cur.... 阅读全文
摘要:
public class Solution { public boolean search(int[] nums, int target) { int len = nums.length; if(len == 0) return false; int ... 阅读全文