![](https://img-blog.csdnimg.cn/20201014180756918.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
算法
老醋
这个作者很懒,什么都没留下…
展开
-
LeetCode: Largest Rectangle in Histogram
Given n non-negative integers representing the histogram's bar height where the width of each bar is 1, find the area of largest rectangle in the histogram. Above is a histogram where width o原创 2016-08-27 20:01:58 · 409 阅读 · 0 评论 -
leetcode 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 [ [2], [3,4], [原创 2016-09-05 10:48:17 · 208 阅读 · 0 评论 -
leetcode Best Time to Buy and Sell Stock
Say 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 share of the stock),原创 2016-09-06 11:03:48 · 253 阅读 · 0 评论 -
最长公共子序列
//最长公共子序列(记住公式即可答出) //公式: 0 ; i=0 || j=0 // C[i][j] = { C[i-1][j-1] ; str[i] == str[j] // max(C[i-1][j],C[i][j-1]; str[i] =/= str[j] int lengest(char* str1, char原创 2016-10-04 22:36:35 · 264 阅读 · 0 评论 -
kmp
void getnext(char *target ,int *next) { int len = strlen(target); next[0] = 0; for(int i=1,k=0;i<len;++i) { while(k>0 && target[i]!=target[k]) k = next[k-1]; if(target[i]==target[k]) k++原创 2016-10-05 08:57:43 · 205 阅读 · 0 评论 -
链表快排
class Solution{ public: ListNode* sortList(ListNode* head) { if(head == NULL || head->next == NULL) return head; ListNode* begin = head, *end = NULL; Quicksort_list(begin, end); return be转载 2017-02-14 16:02:22 · 259 阅读 · 0 评论 -
leetcode Distinct Subsequences
Given a string S and a string T, count the number of distinct subsequences of T in S. A subsequence of a string is a new string which is formed from the original string by deleting some (can be non原创 2016-09-04 20:12:16 · 275 阅读 · 0 评论 -
leetcode Clone Graph
Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors. OJ's undirected graph serialization: Nodes are labeled uniquely. We use # as a separator for each原创 2016-09-15 20:49:06 · 208 阅读 · 0 评论 -
leetcode Set Matrix Zeroes
Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in place. click to show follow up. Follow up: Did you use extra space? A straight forward solution using O(m原创 2016-08-23 20:54:21 · 246 阅读 · 0 评论 -
leetcode Maximal Rectangle
Given a 2D binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area. For example, given the following matrix: 1 0 1 0 0 1 0 1 1 1 1 1 1 1 1 1 0 0 1原创 2016-08-27 22:40:15 · 473 阅读 · 0 评论 -
LeetCode | 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 the total nu原创 2016-08-29 10:39:35 · 315 阅读 · 0 评论 -
leetcode Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum. For this problem, a path is defined as any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The原创 2016-09-09 09:46:00 · 239 阅读 · 0 评论 -
leetcode Restore IP Addresses
Given a string containing only digits, restore it by returning all possible valid IP address combinations. For example: Given "25525511135", return ["255.255.11.135", "255.255.111.35"]. (Order原创 2016-08-30 12:30:57 · 243 阅读 · 0 评论 -
leetcode Unique Binary Search Trees
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example, Given n = 3, there are a total of 5 unique BST's. 1 3 3 2 1 \原创 2016-08-31 22:47:40 · 185 阅读 · 0 评论 -
leetcode Interleaving String
Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. For example, Given: s1 = "aabcc", s2 = "dbbca", When s3 = "aadbbcbcac", return true. When s3 = "aadbbbaccc", r原创 2016-09-01 21:17:01 · 213 阅读 · 0 评论 -
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原创 2016-09-14 10:59:41 · 225 阅读 · 0 评论 -
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 on原创 2016-09-14 14:42:16 · 270 阅读 · 0 评论 -
leetcode Flatten Binary Tree to Linked List
Given a binary tree, flatten it to a linked list in-place. For example, Given 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1原创 2016-09-03 22:27:44 · 214 阅读 · 0 评论