- 博客(25)
- 资源 (14)
- 收藏
- 关注
转载 几句话弄清楚Java参数传值还是传引用
最近刷题用递归解决关于树的问题的时候,在递归函数调用的时候什么时候传入值,什么时候传入引用有疑问,因为这关系到什么时候我们需要恢复现场,什么时候不需要。在网上搜索了一下,感觉这篇总结的非常简单明了,简而言之,基础数据类型(int,char,……)传值,对象类型(Object,数组,容器……)传引用。但是对于String, Integer, Double等等immutable的类型,也是传值需要特殊
2015-01-28 14:58:10 19962 3
原创 LeetCode Path Sum II
Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5 / \
2015-01-28 14:44:23 2186 2
原创 LeetCode Path Sum
Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binary tree and sum = 22
2015-01-28 13:46:02 1551 1
原创 LeetCode Construct Binary Tree from Preorder and Inorder Traversal
Given preorder and inorder traversal of a tree, construct the binary tree.Note:You may assume that duplicates do not exist in the tree.思路分析:这题类似于LeetCode Construct Binary Tree from Inorder and Postord
2015-01-28 12:30:19 2131 1
原创 LeetCode Construct Binary Tree from Inorder and Postorder Traversal
Given inorder and postorder traversal of a tree, construct the binary tree.思路分析:这题主要考察递归,我们可以画一个二叉树的实例来具体分析。比如如果postorder 是84526731,inorder是84521637,首先我们可以知道postorder的最后一个数1必然是root,然后我们可以在inorder里面找到这
2015-01-28 12:24:49 2238 1
原创 LeetCode Merge Sorted Array
Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from B. The
2015-01-27 14:34:16 1651
原创 LeetCode Merge Two Sorted Lists
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.思路分析:这题是 LeetCode Sort List需要使用的merge两个有序链表使得结果仍然有序这个子过程,详细
2015-01-27 13:43:31 1924
原创 LeetCode Sort List
Sort a linked list in O(n log n) time using constant space complexity.思路分析:这题要求在O(n log n) 和常量空间对单链表排序,O(n log n) 的排序算法有快速排序,归并排序和堆排序,对于快速排序,其最坏情况下的时间复杂读是O(n),所以不符合要求。我们可以用归并排序解决这题。用归并排序的好处是平均时间和最坏时间都
2015-01-27 13:29:49 2142 1
原创 LeetCode Unique Paths II
Follow up for "Unique Paths":Now consider if some obstacles are added to the grids. How many unique paths would there be?An obstacle and empty space is marked as 1 and 0 respectively in the grid.For e
2015-01-27 11:27:14 1790
原创 LeetCode Reverse Words in a String
Given an input string, reverse the string word by word.For example,Given s = "the sky is blue",return "blue is sky the".思路分析:这题算法很简单,用一个栈就可以搞定。trick part见如下的说明What constitutes a word?A sequence of non
2015-01-23 14:30:34 1942
原创 LeetCode Word Break
Given a string s and a dictionary of words dict, determine if s can be segmented into a space-separated sequence of one or more dictionary words.For example, givens = "leetcode",dict = ["leet", "code"
2015-01-23 13:13:43 2524
原创 面试题:如何在一千万个不重复整数(电话号码)中查找某个特定数 位运算 bitmap
面试题:某城市有一千万个电话号码,如何快速找到某个电话号码,考虑优化时间和空间复杂度,同时考虑内存限制。同类变形:Given 2MB memory, we want to store 5 million integers in 0~10million range. These integers are unique.1. How to store these integers?2.Given a
2015-01-19 16:52:45 5936 2
原创 LeetCode Single Number
Given an array of integers, every element appears twice except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement it without using extra mem
2015-01-19 15:39:51 1329
原创 LeetCode Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?思路分析:这题比较容易想到的解法是先检查是否有环,然后检查每个node是否在环内,但是是O(N^2)的解
2015-01-19 15:00:32 1759
原创 LeetCode Linked List Cycle
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?思路分析:这题很简单,直接用快慢指针法就可以解决,快指针速度是慢指针速度的2倍,如果有环,它们一定会相遇。AC Code/** * Definition for singly-lin
2015-01-19 14:47:40 1298
原创 LeetCode Jump Game II
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Your goal is to rea
2015-01-19 14:40:52 1544
原创 LeetCode Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4,return 1->4->3->2->5->NULL.Note:Given m, n satisfy the following condi
2015-01-19 14:36:55 1819
原创 LeetCode Reverse Nodes in k-Group
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.If the number of nodes is not a multiple of k then left-out nodes in the end should remain as it is.You
2015-01-19 14:28:33 3166
原创 LeetCode Dungeon Game
The demons had captured the princess (P) and imprisoned her in the bottom-right corner of a dungeon. The dungeon consists of M x N rooms laid out in a 2D grid. Our valiant knight (K) was initially pos
2015-01-12 15:52:30 3605
原创 LeetCode Candy
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least one candy.
2015-01-12 14:56:12 1624
原创 LeetCode Next Permutation
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not possible, it must rearrange it as the lowest possible ord
2015-01-12 14:14:33 1578
原创 LeetCode Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two singly linked lists begins.For example, the following two linked lists:A: a1 → a2 ↘ c
2015-01-05 07:33:08 2939
原创 LeetCode Jump Game
Given an array of non-negative integers, you are initially positioned at the first index of the array.Each element in the array represents your maximum jump length at that position.Determine if you ar
2015-01-05 07:24:32 1664
原创 LeetCode Unique Paths
A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below).The robot can only move either down or right at any point in time. The robot is trying to reach the bott
2015-01-05 07:13:37 1917 1
原创 LeetCode Find Peak Element
A peak element is an element that is greater than its neighbors.Given an input array where num[i] ≠ num[i+1], find a peak element and return its index.The array may contain multiple peaks, in that cas
2015-01-05 06:55:59 3912
LibSVM Java API调用示例程序
2012-12-16
基于机器学习SNS隐私向导分类器的C++及WEKA实现源码
2012-06-03
基于机器学习的SNS隐私保护策略推荐向导的设计与实现
2012-06-03
基于Apriori、FP-Growth及Eclat算法的频繁模式挖掘源程序
2012-04-24
基于Apriori、FP-Growth及Eclat算法的频繁模式挖掘源程序共享版
2012-04-24
基于Kmeans算法、MBSAS算法及DBSCAN算法的newsgroup18828文本聚类器
2012-04-17
基于贝叶斯及KNN算法的newsgroup文本分类器免积分下载版
2012-03-31
基于贝叶斯及KNN算法的newsgroup文本分类器
2012-03-27
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人