原创 分治算法(一)241Different Ways to Add Parentheses【middle】03-02

1、題目 Given a string of numbers and operators, return all possible results from computing all the different possible way

原创 圖(深度優先搜索)491. Increasing Subsequences[Middle]03-18

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

原创 複習一:分治算法

臨近期末,把之前做過的題目(有部分是未做過的)重新做一遍,整合到一起,爲了省時間,就不貼代碼了,只分析思路。 分治算法題目: 1、Search a 2D Matrix II:在一個每行每列都有序的矩陣中搜索某一數字。 2、Kth

原创 最後的作業——NP完全問題證明

a)子圖同構: 令G爲一個環,環上所有頂點數與H的頂點數相同,如果G是H的同構子圖,那麼H就包含了一條Rudrata迴路,因此,Rudrata迴路問題歸約到了子圖同構問題,因此,子圖同構也是NP完全問題 b)最長路徑問題: 令整數

原创 動態規劃——377. Combination Sum IV[Medium]

題目描述 Given an integer array with all positive numbers and no duplicates, find the number of possible combinations tha

原创 複習三-bfs

題目描述 107. Binary Tree Level Order Traversal II DescriptionHintsSubmissionsSolutions Total Accepted: 

原创 動態規劃——72. Edit Distance[HARD]

題目描述 Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each oper

原创 動態規劃——474. Ones and Zeroes[medium]

題目描述 In the computer world, use restricted resource you have to generate maximum benefit is what we always want to pu

原创 動態規劃——62. Unique Paths[medium]

題目描述 A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can

原创 213. House Robber II[Medium]

題目大意 Note: This is an extension of House Robber. After robbing those houses on that street, the thief has found hims

原创 動態規劃——357. Count Numbers with Unique Digits[medium]

題目描述 Given a non-negative integer n, count all numbers with unique digits, x, where 0 ≤ x < 10n. Example: Given n =

原创 動態規劃——303. Range Sum Query - Immutable[easy]

題目描述 Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive. Example:

原创 複習二:dfs

臨近期末,把之前做過的題目(有部分是未做過的)重新做一遍,整合到一起,爲了省時間,就不貼代碼了,只分析思路。 DFS題目: 104:樹的最大深度。 用depth表示深度,遞歸調用計算深度的函數,如果當前深度大於depth,更新dep

原创 動態規劃——392. Is Subsequence

題目描述 Given a string s and a string t, check if s is subsequence of t. You may assume that there is only lower case E

原创 動態規劃——516. Longest Palindromic Subsequence[Medium]

題目描述 Given a string s, find the longest palindromic subsequence's length in s. You may assume that the maximum length