自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(18)
  • 收藏
  • 关注

原创 leetcode Count Numbers with Unique Digits

题目链接 题目的提示已经给的很清楚了 其实这个题我没有反应过来。如果放到组合数学里面。这是个简单题目public class Solution { public int countNumbersWithUniqueDigits(int n) { if(n==0) { return 1; } int t

2016-06-15 22:23:32 251

原创 Retrofit官网文档评注

IntroductionRetrofit turns your HTTP API into a Java interface. 它把一个http的请求用一个接口的方式来实现。比较新奇的想法。public interface GitHubService { @GET("users/{user}/repos") Call<List<Repo>> listRepos(@Path("user")

2016-06-07 21:55:11 370

原创 leetcode word Search

题目链接 深度优先搜索public class Solution { char[][]board; boolean [][]record; int row; int colom; String word; public boolean exist(char[][] board, String word) { this.board=boa

2016-06-06 10:52:41 242

原创 leetcode Restore IP Addresses

题目链接这个题难度倒是没多少。递归回溯。不过要考虑0出来后面必须没有东西。这个特殊情况。public class Solution { String s; List<String> result; StringBuilder sb; public List<String> restoreIpAddresses(String s) { this.s=s;

2016-06-05 11:48:27 253

原创 leetcode Word Break

题目链接动态规划public class Solution { Set<String> wordDict; String s; public boolean wordBreak(String s, Set<String> wordDict) { this.wordDict=wordDict; this.s=s; boolean

2016-06-04 11:38:10 205

原创 leetcode Clone Graph

题目链接这个题目就是用深度优先遍历就好。但是记录方式要更改一下。并不是那个点已经访问过就直接返回。因为一个点可以重复链接自己,也可重复链接别人/** * Definition for undirected graph. * class UndirectedGraphNode { * int label; * List<UndirectedGraphNode> neighbor

2016-06-03 21:18:31 202

原创 leetcode Minimum Height Trees

题目链接这个题有点难度。。 使用的是类似拓扑排序方法。可以逐步的剔除掉树里面的叶子节点。然后,剩下树种仅有叶子节点。那么这两个就是最后的结果。思考的方式就是。我们是从顶端到根的距离最小。那么。我们每次都去掉一层叶子,这样问题没边,还是要从根节点到叶子的最短距离。那么留下来的就可以递归执行去叶子了。public class Solution { public List<Integer> fi

2016-06-03 17:05:51 246

原创 leetcode Remove Duplicates from Sorted List II

题目链接/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } */public class Solution { public ListNode d

2016-06-03 16:06:52 257

原创 leetcode Gas Station

题目链接目前中等难度的题已经有点算法知识了。不再是单纯的数据结构问题了。 这个问题一看就是贪心算法的。因为。路径无限油箱,加油站这类问题贪心算法确实是一个好方法。特别是无限的油箱,没有停车次数的限制。贪心必选。这个题的贪心算法主要是用在如何确定起始点上。在程序中用一个tempsum来计算起始点。如果tempsum小于零那么代表之前确定的起始点A并不能到达现在这个点D。。而且,A到D之间的任何一个点

2016-06-03 15:53:38 203

原创 leetcode Palindrome Partitioning

题目链接 这个题目主要用到了回溯算法。只能说是一个经过优化的递归回溯。如果想提高一点算法效率的话。就要先建立一个表。。表格里面存放从A,到B字符串是不是回文的。这样能够增加一点效率。public class Solution { String s; List<List<String>> result=new LinkedList<List<String>>(); List<

2016-06-03 15:18:38 211

原创 leetcode Group Anagrams

题目链接这个题目的思想就是 拿到一个字符串,然后排序。然后到hash表里面找到对应的加进去。。最后对表进行排序。okpublic class Solution { public List<List<String>> groupAnagrams(String[] strs) { HashMap<String, List<String>> hashMap=new HashMa

2016-06-02 21:12:54 209

原创 leetcode Reverse Linked List II

题目链接这个题目看上去很简单。但是其实考虑的问题有很多。。最特殊情况。如果从第一个就开始反转,那么链表头结点要改一个简单的方法就是增加一个头结点。这样省着改头结点/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNo

2016-06-01 22:06:25 193

原创 leetcode Permutations II

题目链接这个题目其实就是考一个排列的生成算法。这个算法很有名。就是开始不断的增加字典序。所以大家可以随便在网上搜索排列生成算法就好public class Solution { public List<List<Integer>> permuteUnique(int[] nums) { Arrays.sort(nums); List<List<Integer>

2016-06-01 20:35:56 308

原创 leetcode Jump Game

题目链接这个题目很明显的就能想到一个动态规划的算法public class Solution { public boolean canJump(int[] nums) { boolean[] record=new boolean[nums.length]; record[0]=true; for(int i=0;i<nums.length;i+

2016-06-01 19:00:22 192

原创 leetcode Construct Binary Tree from Preorder and Inorder Traversal

题目链接/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution

2016-06-01 17:51:48 195

原创 leetcode Path Sum II

题目链接递归回溯/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solut

2016-06-01 17:10:53 162

原创 leetcode Construct Binary Tree from Inorder and Postorder Traversal

题目链接/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */public class Solution

2016-06-01 16:57:27 396

原创 leetcode Search for a Range

题目链接package newcoder;import java.util.Arrays;public class Solution { public int[] searchRange(int[] nums, int target) { int result[]=new int[]{-1,-1}; int index=Arrays.binarySearch(

2016-06-01 10:57:56 223

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除