- 博客(414)
- 资源 (14)
- 收藏
- 关注
原创 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 1652
原创 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 1300
原创 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 3167
原创 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 1579
原创 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 2940
原创 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
原创 LeetCode First Missing Positive
Given an unsorted integer array, find the first missing positive integer.For example,Given [1,2,0] return 3,and [3,4,-1,1] return 2.Your algorithm should run in O(n) time and uses constant space.思路分析:
2014-12-31 15:07:00 3536
原创 LeetCode Edit Distance
Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)You have the following 3 operations permitted on a word:a) I
2014-12-31 14:42:12 4024
原创 LeetCode Climbing Stairs
You are climbing a stair case. It takes n steps to reach to the top.Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?思路分析:考察DP,定义ClimbWays数组,ClimbWays[n]
2014-11-29 05:25:23 1837
原创 LeetCode Search in Rotated Sorted Array
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array return its inde
2014-11-29 04:08:29 2242
原创 LeetCode Search Insert Position
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).You are given a target value to search. If found in the array return its inde
2014-11-29 03:35:44 1794
原创 LeetCode Maximum Product Subarray
Find the contiguous subarray within an array (containing at least one number) which has the largest product.For example, given the array [2,3,-2,4],the contiguous subarray [2,3] has the largest produc
2014-11-29 03:00:31 1999
原创 LeetCode Permutations
Given a collection of numbers, return all possible permutations.For example,[1,2,3] have the following permutations:[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], and [3,2,1].思路分析:这题是Permutations II问题的简
2014-11-23 13:01:17 1968
原创 LeetCode Permutations II
题目 Given a collection of numbers that might contain duplicates, return all possible unique permutations.For example,[1,1,2] have the following unique permutations:[1,1,2], [1,2,1], and [2,1,1].思路分析:Pe
2014-11-23 12:56:52 2331
原创 LeetCode Merge Intervals
题目:Given a collection of intervals, merge all overlapping intervals.For example,Given [1,3],[2,6],[8,10],[15,18],return [1,6],[8,10],[15,18].思路分析:这题关键要想到先对区间排序,然后从前向后扫描,如果下一个没法合并,就添加一个区间;如果可以,还要继续向后看,
2014-11-23 11:02:09 2094
原创 LeetCode Container With Most Water
Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two
2014-11-16 10:37:08 2540 1
原创 LeetCode Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()()"思路分析:
2014-11-16 10:28:18 2120
原创 LeetCode Gas Station
There are N gas stations along a circular route, where the amount of gas at station i is gas[i].You have a car with an unlimited gas tank and it costs cost[i] of gas to travel from station i to its ne
2014-11-10 14:01:07 1868
转载 LeetCode 问题难度,面试出现频率及问题相关数据结构和算法
转载自http://blog.csdn.net/kenden23/article/details/14109347。统计了各个问题的难度,频率,数据结构和算法LeetCode Question Difficulty Distribution IDQuestionDiffFreqData StructureAlgorithms 1Two Sum25arra
2014-11-09 12:52:48 9458
原创 LeetCode Two Sum
Given an array of integers, find two numbers such that they add up to a specific target number.The function twoSum should return indices of the two numbers such that they add up to the target, where i
2014-11-09 11:36:47 2374
原创 LeetCode Validate Binary Search Tree
LeetCode Validate Binary Search TreeGiven a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys
2014-11-09 11:02:57 1841
原创 LeetCode Maximum Subarray
LeetCode Maximum Subarray Find the contiguous subarray within an array (containing at least one number) which has the largest sum.For example, given the array [−2,1,−3,4,−1,2,1,−5,4],the contiguous su
2014-10-30 05:39:13 2176
原创 LeetCode Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ... n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4], [2,3], [1,2], [1,3], [1,4],]
2014-10-30 05:35:09 1480
原创 LeetCode Triangle
LeetCode TriangleGiven a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below.For example, given the following triangle[ [2], [3
2014-10-30 05:24:45 1915
转载 CMPSCI 683 AI 第三讲 启发式搜索-A*算法
作为AI课的预习笔记,搜索了下启发式搜索 A*算法的一些经典资料,整理到下面,这个算法很有意思,有时间自己实现一下。[1] 一个老外写的A*算法实例解说,写的非常翔实易懂,这是一个中文翻译版 http://blog.csdn.net/crayondeng/article/details/12342989[2] 这个基于[1]的阅读,添加了自己的理解性的注释 http://www.cnblogs.c
2014-10-29 13:11:46 2332 1
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关注的人