原创 [sicily] 1003. hit or miss

#include <iostream> #include <queue> using namespace std; int main() { int n; while(cin >> n) { for (i

原创 [sicily] 1020. Big Integer

1020. Big Integer Constraints Time Limit: 1 secs, Memory Limit: 32 MB Description Long long

原创 [leetcode] 64. Minimum Path Sum Add to List

64. Minimum Path Sum Add to List Given a m x n grid filled with non-negative numbers, find a path from top left to bott

原创 【算法概論】習題8.12證明題

《算法概論》習題8.12證明題 題目 k-生成樹問題是這樣一個問題: 輸入:無向圖G=(V,E) 輸出:G的一個生成樹,其中所有節點度數都不超過k——如果該樹存在。 請證明對任意k>=2: (a)k-生成樹問題是一個搜索問

原创 [leetcode] 85. Maximal Rectangle

85. Maximal Rectangle Given a 2D binary matrix filled with 0’s and 1’s, find the largest rectangle containing only 1’s

原创 [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 t

原创 【算法概論】習題8.3答案

【算法概論】習題8.3答案 題目 8.3 吝嗇SAT問題是這樣的:給定一組子句(每個子句都是其中文字的析取)和整數k,求一個最多有k個變量爲true的滿足賦值——如果該賦值存在。證明吝嗇SAT是NP-完全問題。 解答 要證明一個問題是NP

原创 [Leetcode] 121. Best Time to Buy and Sell Stock

121. Best Time to Buy and Sell Stock Say you have an array for which the i-th element is the price of a given stock on

原创 [leetcode] 567. Permutation in String

567. Permutation in String Given two strings s1 and s2, write a function to return true if s2 contains the permutation

原创 [Leetcode] 57. Insert Interval

57. Insert Interval Given a set of non-overlapping intervals, insert a new interval into the intervals(merge if necess

原创 [Leetcode] 41. First Missing Positive

41. First Missing Positive Given an unsorted integer array, find the first missing positive integer. For example, Give

原创 【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 des

原创 【leetcode】215. Kth Largest Element in an Array

【leetcode】215. Kth Largest Element in an Array Find the kth largest element in an unsorted array. Note that it is the k

原创 [leetcode] 491. Increasing Subsequences

Given an integer array, your task is to find all the different possible increasing subsequences of the given array, and

原创 [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 i-th element is the price of a given stock