![](https://img-blog.csdnimg.cn/20201014180756930.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法设计与分析
zerokk9912
这个作者很懒,什么都没留下…
展开
-
Dijkstra 算法 -方法、算法、代码和正确性的证明
Dijkstra 算法 -方法、算法、代码和正确性的证明 摘要本文介绍Dijkstra算法,包括方法、算法、正确性的证明和算法C++的实现。§1 Dijkstra算法方法介绍算法适用范围:Dijkstra算法解决的是带权重的问题的有向图上单源最短路径问题,该算法要求所有边的权重都为非负值。D原创 2017-06-09 19:40:29 · 3576 阅读 · 0 评论 -
LeetCode: 330. Patching Array
330. Patching Array题目Given a sorted positive integer array nums and an integer n, add/patch elements to the array such that any number in range [1, n] inclusive can be formed by the sum of some el...原创 2018-10-26 12:03:27 · 231 阅读 · 0 评论 -
LeetCode: 55. Jump Game
55. 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...原创 2018-10-26 15:43:32 · 153 阅读 · 0 评论 -
LeetCode: 72. Edit Distance
72. Edit Distance题目Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2.You have the following 3 operations permitted on a word:Insert a cha...原创 2018-10-30 20:06:42 · 189 阅读 · 0 评论 -
LeetCode: 63. Unique Paths II
63. Unique Paths II题目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 i...原创 2018-11-06 13:34:32 · 141 阅读 · 0 评论 -
LeetCode: 87. Scramble String
87. Scramble String题目 Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representation of s1 = "great": ...原创 2018-11-06 19:31:16 · 118 阅读 · 0 评论 -
LeetCode: 32. Longest Valid Parentheses
32. Longest Valid Parentheses题目Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring.Example 1:Input: "(()"Output: ...原创 2018-11-04 17:44:16 · 141 阅读 · 0 评论 -
LeetCode: 95. Unique Binary Search Trees II
95. Unique Binary Search Trees II题目 Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1 ... n. Example: Input: 3 Output: [  ...原创 2018-11-13 19:32:42 · 125 阅读 · 0 评论 -
LeetCode: 120. Triangle
120. Triangle题目 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 [ ...原创 2018-11-20 20:38:47 · 137 阅读 · 0 评论 -
LeetCode: 97. Interleaving String
97. Interleaving String题目 Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. Example 1: Input: s1 = "aabcc", s2 = "dbbca", s3 = "aadbbc原创 2018-11-16 22:37:12 · 141 阅读 · 0 评论 -
LeetCode: 115. Distinct Subsequences
题目Given a string S and a string T, count the number of distinct subsequences of Swhich equals T.A subsequence of a string is a new string which is formed from the original string by deleting some ...原创 2018-11-24 20:50:29 · 114 阅读 · 0 评论 -
LeetCode: 123. Best Time to Buy and Sell Stock III
123. Best Time to Buy and Sell Stock III题目 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 comple...原创 2018-12-02 16:33:39 · 2329 阅读 · 0 评论 -
LeetCode: 57. Insert Interval
57. 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 the...原创 2018-12-06 14:56:43 · 151 阅读 · 0 评论 -
LeetCode: 132. Palindrome Partitioning II
132. Palindrome Partitioning II题目Given a string s, partition s such that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning of s.Example:...原创 2018-12-06 16:02:01 · 147 阅读 · 0 评论 -
LeetCode:210. Course Schedule II
题目There are a total of n courses you have to take, labeled from 0 to n-1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is expressed as a...原创 2018-10-16 23:56:26 · 147 阅读 · 0 评论 -
LeetCode:134. Gas Station
134. 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 f...原创 2018-10-18 13:49:00 · 128 阅读 · 0 评论 -
LeetCode:64. Minimum Path Sum
64. Minimum Path Sum题目Given 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...原创 2018-09-28 20:27:51 · 105 阅读 · 0 评论 -
LeetCode:1 Two Sum
1. Two Sum题目 Given an array of integers, return indices of the two numbers such that they add up to a specific target.You may assume that each input would have exactly one solution, and you may ...原创 2018-09-05 20:47:44 · 95 阅读 · 0 评论 -
LeetCode:3 Longest Substring Without Repeating Characters
3. Longest Substring Without Repeating Characters题目 Given a string, find the length of the longest substring without repeating characters. Input: “pwwkew” Output: 3 Explanation: The...原创 2018-09-09 13:50:20 · 123 阅读 · 0 评论 -
LeetCode:67 Add Binary
67. Add Binary题目Given two binary strings, return their sum (also a binary string).The input strings are both non-empty and contains only characters 1 or 0. Input: a = “11”, b = “1” Output...原创 2018-09-06 17:06:01 · 91 阅读 · 0 评论 -
LeetCode:41. First Missing Positive
41. First Missing Positive题目Given an unsorted integer array, find the smallest missing positive integer.Example:Input: [7,8,9,11,12]Output: 1Note: Your algorithm should run in O(n) time and ...原创 2018-09-16 11:00:23 · 163 阅读 · 0 评论 -
LeetCode:8. String to Integer (atoi)
8. String to Integer (atoi)题目 Implement atoi which converts a string to an integer.The function first discards as many whitespace characters as necessary until the first non-whitespace character...原创 2018-09-13 15:30:12 · 129 阅读 · 0 评论 -
LeetCode:5. Longest Palindromic Substring
5. Longest Palindromic Substring题目Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000.Example Input: "babad" Outp原创 2018-09-18 20:13:35 · 111 阅读 · 0 评论 -
最小生成树MST -- Prim 算法实现
最小生成树MST最小生成树定义:一个有 n 个结点的连通图的生成树是原图的极小连通子图,且包含原图中的所有 n 个结点,并且有保持图连通的最少的边。Prim algorithm: Prim算法简述 1).输入:一个加权连通图,其中顶点集合为V,边集合为E; 2).初始化:Vnew= {x},其中x为集合V中的任一节点(起始点),Enew= {},为空; 3).重复下列操作,直到原创 2017-05-20 20:28:25 · 538 阅读 · 0 评论 -
LeetCode:310. Minimum Height Trees
310. Minimum Height Trees题目For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those wi...原创 2018-09-30 22:31:51 · 331 阅读 · 0 评论 -
LeetCode:22. Generate Parentheses
22. 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:[ "((()))&amp原创 2018-09-20 16:05:52 · 124 阅读 · 0 评论 -
LeetCode:50. Pow(x, n)
50. Pow(x, n)题目Implement pow(x, n), which calculates x raised to the power n (xn).Example 1:Input: 2.00000, 10Output: 1024.00000Example 2:Input: 2.10000, 3Output: 9.26100Example 3:Input:...原创 2018-09-26 21:33:07 · 98 阅读 · 0 评论 -
LeetCode:785. Is Graph Bipartite?
785. Is Graph Bipartite?题目Given an undirected graph, return true if and only if it is bipartite.Recall that a graph is bipartite if we can split it’s set of nodes into two independent subsets A a...原创 2018-10-12 00:12:30 · 155 阅读 · 0 评论 -
LeetCode:207. Course Schedule
207. Course Schedule题目There are a total of n courses you have to take, labeled from 0 to n-1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, whi...原创 2018-10-12 23:58:25 · 162 阅读 · 0 评论 -
LeetCode:332. Reconstruct Itinerary
332. Reconstruct Itinerary题目Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a ma...原创 2018-10-07 13:14:13 · 255 阅读 · 0 评论 -
Capacitated Facility Location Problem
项目地址介绍Suppose there are n facilities and m customers. We wish to choose:which of the n facilities to openthe assignment of customers to facilitiesThe objective is to minimize the sum of the o...原创 2018-12-23 01:56:10 · 475 阅读 · 0 评论