原创 【位運算】B011_LC_循環碼排列(回溯 / 格雷碼變形 + 旋轉 (代辦))

一、Problem Given 2 integers n and start. Your task is return any permutation p of (0,1,2…,2^n -1) such that : p[0]

原创 【網格 dp】A006_LC_鋪瓷磚(三種切分法)

一、Problem 你是一位施工隊的工長,根據設計師的要求準備爲一套設計風格獨特的房子進行室內裝修。 房子的客廳大小爲 n x m,爲保持極簡的風格,需要使用盡可能少的 正方形 瓷磚來鋪蓋地面。假設正方形瓷磚的規格不限,邊長都是整

原创 【狀壓 dp】A000_LC_轉化爲全零矩陣的最少反轉次數(回溯 / dp / bfs)

一、Problem Given a m x n binary matrix mat. In one step, you can choose one cell and flip it and all the four neighb

原创 【貪心】B040_LC_重構 2 行二進制矩陣(構造 + 規定順序)

一、Problem Given the following details of a matrix with n columns and 2 rows : The matrix is a binary matrix, which

原创 【區間 dp】B013_LC_最長遞增子序列的個數(累加)

一、Problem Given an unsorted array of integers, find the number of longest increasing subsequence. Input: [1,3,5,4,7

原创 【回溯】A066_LC_串聯字符串的最大長度(暴搜 / 二進制枚舉)

一、Problem Given a list of words, list of single letters (might be repeating) and score of every character. Return

原创 【網格 dp】A005_LC_二指輸入的的最小距離(枚舉上一個狀態)

一、Problem You have a keyboard layout as shown above in the XY plane, where each English uppercase letter is locate

原创 【貪心】B039_LC_劃分數組爲連續數字的集合(排序 + map)

一、Problem Given an array of integers nums and a positive integer k, find whether it’s possible to divide this array

原创 【數組】B075_LC_除自身以外數組的乘積(前綴積+後綴積 / 前後枚舉)

一、Problem Given an array nums of n integers where n > 1, return an array output such that output[i] is equal to th

原创 【並查集】B010_LC_連通網絡的操作次數(統計多餘的網線)

一、Problem There are n computers numbered from 0 to n-1 connected by ethernet cables connections forming a network w

原创 【數論】B055_LC_順次數(構造法)

一、Problem An integer has sequential digits if and only if each digit in the number is one more than the previous di

原创 【棧】B013_LC_移除無效的括號(棧 + 標記)

一、Problem Given a string s of ‘(’ , ‘)’ and lowercase English characters. Your task is to remove the minimum number

原创 【網格 dp】C003_LC_統計全爲 1 的正方形子矩陣(擴大一圈)

一、Problem Given a m * n matrix of ones and zeros, return how many square submatrices have all ones. Input: matrix =

原创 【網格 dp】A004_LC_最大得分的路徑數目(bfs / dp)

一、Problem You are given a square board of characters. You can move on the board starting at the bottom right square

原创 【貪心】B038_LC_刪除被覆蓋區間(排序)

一、Problem Given a list of intervals, remove all intervals that are covered by another interval in the list. Interva