原创 算法概論習題8.8——證明精確的4SAT是NP-完全問題
題目: 在精確的4SAT(EXACT 4SAT)問題中,輸入爲一組字句,每個字句都是恰好4個文字的析取,且每個變量最多在每個字句中出現一次。目標是求它的滿足賦值——如果該賦值存在。證明精確的4SAT是NP完全問題。 證明如下: 由於3SA
原创 leetcode——Best Time to Buy and Sell StockⅠ& Ⅱ& Ⅲ & Ⅳ
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
原创 leetcode——Largest Number
原題: Given a list of non negative integers, arrange them such that they form the largest number. For example, given [
原创 leetcode——Maximum Subarray
原題目: Find the contiguous subarray within an array (containing at least one number) which has the largest sum. For ex
原创 leetcode——Decode String
原題目: Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string], where the encoded
原创 leetcode——Majority Element
原題目: Given an array of size n, find the majority element. The majority element is the element that appears more than
原创 leetcode——Unique Paths & Unique PathsⅡ
Unique Paths A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The
原创 leetcode——Kth Largest Element in an Array
原題目: Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order,
原创 leetcode——Different Ways to Add Parentheses
原題目: Given a string of numbers and operators, return all possible results from computing all the different possible w
原创 leetcode——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)
原创 leetcode——Missing Number
原題目: Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the
原创 leetcode——Climbing Stairs
原題目: You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 step