- 博客(10)
- 资源 (1)
- 收藏
- 关注
原创 leetcode 319 Bulb Switcher
1 暴力解法(超时): package leetcode;public class Solution319 { public int bulbSwitch(int n) { if(n == 0){ return 0; } boolean[] bulbs = new boolean[n]; int co
2016-05-31 23:03:01 306
转载 协同过滤算法
协同过滤算法详解: csdn blog:http://blog.csdn.net/acdreamers/article/details/44672305
2016-05-31 09:51:47 281
原创 KMP算法详解
KMP算法遇见很多次了,一没有弄明白。KMP算法是字符串匹配的经典算法,一次去百度面试的时候看隔壁的哥们对这个算法熟的飞起,遂下定决心搞明白这个算法。说起字符串匹配,最直接的想法就是用两次循环。时间复杂度大概是O(m*n),有没有更高效的算法和。看下面的例子:一般的匹配过程:code: * 暴力破解法 * @param ts 主串 * @param ps 模式串
2016-05-26 16:11:20 363
转载 leetcode 350. Intersection of Two Arrays II
350. Intersection of Two Arrays II My SubmissionsQuestionEditorial SolutionTotal Accepted: 4482 Total Submissions: 10704 Difficulty: EasyGiven two arrays, write a function to
2016-05-26 02:38:22 927
原创 leetcode Solution129
129. Sum Root to Leaf Numbers My SubmissionsQuestionEditorial SolutionTotal Accepted: 77138 Total Submissions: 234445 Difficulty: MediumGiven a binary tree containing digits
2016-05-25 11:25:21 770
原创 199. Binary Tree Right Side View
code:层次遍历打印每层最后一个/** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode(int x) { val = x; } * } */ pu
2016-05-25 09:56:53 239
原创 leetcode 349
public class Solution { public int[] intersection(int[] nums1, int[] nums2) { HashSet set = new HashSet(); for(int i = 0;i < nums2.length; ++i) { for(int j = 0;j < num
2016-05-24 10:06:45 471
原创 leetcode 59 Spiral Matrix II 螺旋矩阵的打印
历时2个小时弄懂了螺旋矩阵的代码;小结如下:问题:Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.For example,Given n = 3,You should return the following matrix
2016-05-23 22:23:23 466
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人