- 博客(24)
- 收藏
- 关注
原创 算法概论习题 8.22 NP-完全问题证明
题目:8.22 问题描述: 在任务调度,它常常可以用图进行每个任务的节点和有向边的任务我的任务,如果我是一个先决条件J.这个有向图描绘的优先约束的调度问题。显然,当且仅当图是循环的时,调度是可能的;如果它不是,我们想确定必须丢弃的最小数量的约束,以便使其循环。 给定一个有向图G =(V,E),子集E0⊆E称为反馈弧集如果边E0呈现G环的去除。 反馈弧集(FAS):给定一个有向图G
2017-01-07 21:03:47
1187
原创 【leetcode】45. 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
2016-10-18 23:32:02
305
原创 【leetcode】55. Jump Game
Difficulty:Medium 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 th
2016-10-18 23:13:24
289
原创 【leetcode】188. Best Time to Buy and Sell Stock IV
Difficulty:Hard Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most k transactions.
2016-10-18 22:42:04
276
原创 【leetcode】123. Best Time to Buy and Sell Stock III
Difficulty:Hard Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete at most two transac
2016-10-09 00:52:11
304
原创 【leetcode】122. Best Time to Buy and Sell Stock II
Difficulty:Medium Say you have an array for which the ith element is the price of a given stock on day i. Design an algorithm to find the maximum profit. You may complete as many transactions
2016-10-09 00:46:30
241
原创 【leetcode】121. Best Time to Buy and Sell Stock
Difficulty:Easy ay you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction (ie, buy one and sell one
2016-10-09 00:40:31
247
原创 【leetcode】75. Sort ColorsD
Difficulty:Medium Given an array with n objects colored red, white or blue, sort them so that objects of the same color are adjacent, with the colors in the order red, white and blue. Here, we
2016-09-30 00:49:40
306
原创 【leetcode】215. Kth Largest Element in an Array
Difficulty:Medium Find 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, Given [3,2,1,5
2016-09-30 00:36:19
372
原创 【leetcode】4. Median of Two Sorted Arrays
Difficulty:Hard There are two 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)). E
2016-09-29 23:43:53
321
原创 【leetcode】34. Search for a Range
Difficulty:medium Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's runtime complexity must be in the order of O(log n). If t
2016-09-21 10:28:46
348
原创 【leetcode】74. Search a 2D Matrix
Difficulty:medium Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted from left to right.Th
2016-09-21 09:49:25
291
原创 【leetcode】35. Search Insert Position
Difficulty:medium Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You may assume no d
2016-09-21 09:35:18
292
原创 【leetcode】33. Search in Rotated Sorted Array
Difficulty:hard 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
2016-09-20 00:27:18
350
原创 【leetcode】162. Find Peak Element
Difficulty:medium 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
2016-09-20 00:14:58
394
原创 【leetcode】120. Triangle
Difficulty:medium Given 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 [
2016-09-14 12:15:46
366
原创 【leetcode】80. Remove Duplicates from Sorted Array II
Difficulty:Medium Follow up for "Remove Duplicates": What if duplicates are allowed at most twice? For example, Given sorted array nums = [1,1,1,2,2,3], Your function should return length
2016-09-14 12:04:50
247
原创 318. Maximum Product of Word Lengths
Difficulty:Medium Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will
2016-09-13 23:53:16
396
原创 383. Ransom Note
Difficulty:easy Given an arbitrary ransom note string and another string containing letters from all the magazines, write a function that will return true if the ransom not
2016-09-12 23:43:35
351
原创 387. First Unique Character in a String
Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: s = "leetcode" return 0. s = "loveleetcode", return 2. Note:
2016-09-12 23:36:28
260
原创 【leetcode】312. Burst Balloons
Difficulty:Hard Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst ballo
2016-09-06 23:12:10
340
原创 【leetcode】167. Two Sum II - Input array is sorted
Difficulty:Medium Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum should return indi
2016-09-05 23:34:29
373
原创 【leetcode】347. Top K Frequent Elements
Difficulty:medium Given a non-empty array of integers, return the k most frequent elements. For example, Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: You may assume k is always v
2016-09-05 23:17:51
417
原创 【leetcode】Missing Number
Difficulty:medium Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example, Given nums = [0, 1, 3] return 2. Note:
2016-09-05 23:03:06
245
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅