会员
众包
新闻
博问
闪存
赞助商
HarmonyOS
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
Vision_World
博客园
首页
新随笔
联系
订阅
管理
上一页
1
···
7
8
9
10
11
12
13
下一页
2015年11月29日
[LeetCode]H-Index II
摘要: 二分搜索public class Solution { public int hIndex(int[] citations) { int length = citations.length; if (length == 0) { return ...
阅读全文
posted @ 2015-11-29 06:56 Weizheng_Love_Coding
阅读(126)
评论(0)
推荐(0)
2015年11月28日
[LeetCode]Missing Number
摘要: public class Solution { public int missingNumber(int[] nums) { int n = 0; for (int num : nums) { n = Math.max(n, num); ...
阅读全文
posted @ 2015-11-28 15:38 Weizheng_Love_Coding
阅读(101)
评论(0)
推荐(0)
[LeetCode]Single Number III
摘要: 先找到两个cand在某一位不相同, 在分别异或public class Solution { public int[] singleNumber(int[] nums) { int tmp = nums[0]; for (int i = 1; i < nums.le...
阅读全文
posted @ 2015-11-28 15:33 Weizheng_Love_Coding
阅读(85)
评论(0)
推荐(0)
[LeetCode]Shortest Word Distance III
摘要: public class Solution { public int shortestWordDistance(String[] words, String word1, String word2) { int pre1 = -1; int pre2 = -1; ...
阅读全文
posted @ 2015-11-28 09:44 Weizheng_Love_Coding
阅读(131)
评论(0)
推荐(0)
[LeetCode]Shortest Word Distance II
摘要: public class WordDistance { private HashMap> map = new HashMap>(); public WordDistance(String[] words) { for (int i = 0; i list = map.co...
阅读全文
posted @ 2015-11-28 09:33 Weizheng_Love_Coding
阅读(142)
评论(0)
推荐(0)
[LeetCode]Majority Element II
摘要: public class Solution { public List majorityElement(int[] nums) { int can1 = 0, can2 = 0, num1 = 0, num2 = 0; for (int num : nums) { ...
阅读全文
posted @ 2015-11-28 09:07 Weizheng_Love_Coding
阅读(127)
评论(0)
推荐(0)
[LeedCode]Sparse Matrix Multiplication
摘要: 这个题目考点在于矩阵中有很多0的时候怎么处理。我是创建了一个Node的数据结构,分别存index和值。看网上有个小哥是把index和值分别存在 i 和i + 1 的位置,感觉也很好,不过算法复杂度本质没有变化。public class Solution { public int[][] mul...
阅读全文
posted @ 2015-11-28 08:39 Weizheng_Love_Coding
阅读(131)
评论(0)
推荐(0)
2015年11月27日
[LeetCode]Kth Smallest Element in a BST
摘要: public class Solution { TreeNode result = new TreeNode(0); public int kthSmallest(TreeNode root, int k) { helper(root, k); return ...
阅读全文
posted @ 2015-11-27 16:33 Weizheng_Love_Coding
阅读(90)
评论(0)
推荐(0)
[LeetCode]Shortest Word Distance
摘要: public class Solution { public int shortestDistance(String[] words, String word1, String word2) { int pre1 = -1; int pre2 = -1; ...
阅读全文
posted @ 2015-11-27 16:14 Weizheng_Love_Coding
阅读(129)
评论(0)
推荐(0)
[LeetCode]Remove Duplicates from Sorted Array II
摘要: 这是我最开始的做法,两个指针,一个count计数,但是思路不是很清晰,代码上也有些冗余public class Solution { public int removeDuplicates(int[] nums) { int length = nums.length; ...
阅读全文
posted @ 2015-11-27 12:13 Weizheng_Love_Coding
阅读(103)
评论(0)
推荐(0)
上一页
1
···
7
8
9
10
11
12
13
下一页
公告