算法
文章平均质量分 57
yang蜗牛
中山大学16级数据科学与计算机学院软件工程硕士,研究方向为自然语言处理,基于深度学习的文本情感分析
展开
-
【leetcode】215. Kth Largest Element in an Array
【leetcode】215. Kth Largest Element in an ArrayFind the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element.For example,原创 2017-03-06 01:06:18 · 434 阅读 · 0 评论 -
[leetcode] Median of Two Sorted Arrays
[4] Median of Two Sorted Arrays There are tow sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log(m+n原创 2017-06-03 12:05:54 · 642 阅读 · 0 评论 -
【算法概论】习题8.12证明题
《算法概论》习题8.12证明题题目k-生成树问题是这样一个问题: 输入:无向图G=(V,E) 输出:G的一个生成树,其中所有节点度数都不超过k——如果该树存在。 请证明对任意k>=2: (a)k-生成树问题是一个搜索问题。 (b)k-生成树问题是NP-完全的。解答(a)一个搜索问题的定义是:任何可能解的正确性都能快速地被验证,而快速指的是能够在多项式时间内被验证。证明k-生原创 2017-07-03 21:18:11 · 719 阅读 · 0 评论 -
【算法概论】习题8.3答案
【算法概论】习题8.3答案题目8.3 吝啬SAT问题是这样的:给定一组子句(每个子句都是其中文字的析取)和整数k,求一个最多有k个变量为true的满足赋值——如果该赋值存在。证明吝啬SAT是NP-完全问题。解答要证明一个问题是NP-完全问题,需要证明以下两点: 1. 它是一个NP问题,且 2. 其他属于NP的问题都可归约成它。第一点的证明很简单:为了找到一个最多有k个变量为t原创 2017-07-03 20:44:23 · 1148 阅读 · 0 评论 -
[leetcode] 76. Minimum Window Substring
76. Minimum Window Substring题目:Given a string S and a string T, find the minimum window in S which will contain all the characters in T in complexity O(n).For example, S = “ADOBECODEBANC” T = “ABC”原创 2017-05-08 09:52:41 · 458 阅读 · 0 评论 -
[Leetcode] 41. First Missing Positive
41. First Missing PositiveGiven 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原创 2017-05-14 21:47:13 · 494 阅读 · 0 评论 -
[leetcode] 91. Decode Ways
91. Decode Ways题目A message containing letters from A-Z is being encoded to numbers using the following mapping:‘A’ -> 1 ‘B’ -> 2 … ‘Z’ -> 26 Given an encoded message containing digits, determine th原创 2017-04-23 19:15:50 · 341 阅读 · 0 评论 -
[lletcode]Word Break
Word Break题目:Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine if s can be segmented into a space-separated sequence of one or more dictionary words.原创 2017-04-23 18:46:49 · 422 阅读 · 0 评论 -
【leetcode】406. Queue Reconstruction by Height
406. Queue Reconstruction by Height题目Suppose you have a random list of people standing in a queue. Each person is described by a pair of integers (h, k), where h is the height of the person and k is th原创 2017-03-26 21:01:07 · 392 阅读 · 0 评论 -
【Leetcode】Jump Game
55. Jump GameGiven 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.Determi原创 2017-04-02 23:06:08 · 381 阅读 · 0 评论 -
[leetcode] 64. Minimum Path Sum Add to List
64. Minimum Path Sum Add to ListGiven a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.Note: You can only m原创 2017-04-09 22:53:09 · 498 阅读 · 0 评论 -
【leetcode】133. Clone Graph
133. Clone Graph这道题目的意思是:对一个无向图进行深拷贝,即需要申请一个新的空间,并将原来的无向图中的节点及相关信息拷贝到这个新的空间。因此解题思路其实就是对这个无向图进行遍历,并且一边遍历一边深拷贝即可。对于无向图的遍历,可以采用深度遍历(DFS)和广度遍历(BFS)完成,两者的时间复杂度和空间复杂度都是O(n)。方法一:深度遍历(DFS)// Definition for un原创 2017-03-12 21:02:51 · 638 阅读 · 0 评论 -
[Leetcode] 57. Insert Interval
Insert Interval Given a set of non-overlapping intervals, insert a new interval into the intervals(merge if necessary). You may assume that the intervals were initially sorted according to their star原创 2017-06-26 10:49:53 · 411 阅读 · 0 评论