随笔分类 -  DP

摘要:We have two types of tiles: a 2x1 domino shape, and an "L" tromino shape. These shapes may be rotated. Given N, how many ways are there to tile a 2 x 阅读全文
posted @ 2019-03-19 20:47 Veritas_des_Liberty 阅读(310) 评论(0) 推荐(0)
摘要:In a 2D grid from (0, 0) to (N-1, N-1), every cell contains a 1, except those cells in the given list mines which are 0. What is the largest axis-alig 阅读全文
posted @ 2019-03-18 22:26 Veritas_des_Liberty 阅读(294) 评论(0) 推荐(0)
摘要:On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed). Once you pay the cost, you can either climb one or two steps. Y 阅读全文
posted @ 2019-03-15 12:27 Veritas_des_Liberty 阅读(334) 评论(0) 推荐(0)
摘要:In a N x N grid representing a field of cherries, each cell is one of three possible integers. 0 means the cell is empty, so you can pass through; 1 m 阅读全文
posted @ 2019-03-15 09:44 Veritas_des_Liberty 阅读(281) 评论(0) 推荐(0)
摘要:Given an array nums of integers, you can perform operations on the array. In each operation, you pick any nums[i] and delete it to earn nums[i] points 阅读全文
posted @ 2019-03-14 22:13 Veritas_des_Liberty 阅读(216) 评论(0) 推荐(0)
摘要:Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal. Example 1: Example 2: Note: 0 < s1.length, s2.len 阅读全文
posted @ 2019-03-14 20:53 Veritas_des_Liberty 阅读(248) 评论(0) 推荐(0)
摘要:In a given array nums of positive integers, find three non-overlapping subarrays with maximum sum. Each subarray will be of size k, and we want to max 阅读全文
posted @ 2019-03-13 18:17 Veritas_des_Liberty 阅读(219) 评论(0) 推荐(0)
摘要:Given a string S, find the number of different non-empty palindromic subsequences in S, and return that number modulo 10^9 + 7. A subsequence of a str 阅读全文
posted @ 2019-03-13 17:06 Veritas_des_Liberty 阅读(275) 评论(0) 推荐(0)
摘要:On an NxN chessboard, a knight starts at the r-th row and c-th column and attempts to make exactly K moves. The rows and columns are 0 indexed, so the 阅读全文
posted @ 2019-03-13 13:25 Veritas_des_Liberty 阅读(305) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the number of longest increasing subsequence. Example 1: Example 2: Note: Length of the given array will be 阅读全文
posted @ 2019-03-13 12:44 Veritas_des_Liberty 阅读(179) 评论(0) 推荐(0)
摘要:There is a strange printer with the following two special requirements: The printer can only print a sequence of the same character each time. At each 阅读全文
posted @ 2019-03-12 16:16 Veritas_des_Liberty 阅读(242) 评论(0) 推荐(0)
摘要:Initially on a notepad only one character 'A' is present. You can perform two operations on this notepad for each step: Given a number n. You have to 阅读全文
posted @ 2019-03-12 15:30 Veritas_des_Liberty 阅读(239) 评论(0) 推荐(0)
摘要:You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. Now, we define a pair (c, d) can follow an 阅读全文
posted @ 2019-03-11 16:02 Veritas_des_Liberty 阅读(180) 评论(0) 推荐(0)
摘要:A message containing letters from A-Z is being encoded to numbers using the following mapping way: 'A' -> 1 'B' -> 2 ... 'Z' -> 26 Beyond that, now th 阅读全文
posted @ 2019-03-10 22:27 Veritas_des_Liberty 阅读(299) 评论(0) 推荐(0)
摘要:Given two integers n and k, find how many different arrays consist of numbers from 1 to n such that there are exactly k inverse pairs. We define an in 阅读全文
posted @ 2019-03-10 20:30 Veritas_des_Liberty 阅读(369) 评论(0) 推荐(0)
摘要:Given a positive integer n, find the number of non-negative integers less than or equal to n, whose binary representations do NOT contain consecutive 阅读全文
posted @ 2019-03-09 22:24 Veritas_des_Liberty 阅读(302) 评论(0) 推荐(0)
摘要:There is an m by n grid with a ball. Given the start coordinate (i,j) of the ball, you can move the ball to adjacent cell or cross the grid boundary i 阅读全文
posted @ 2019-03-08 21:51 Veritas_des_Liberty 阅读(294) 评论(0) 推荐(0)
摘要:Given a positive integer n, return the number of all possible attendance records with length n, which will be regarded as rewardable. The answer may b 阅读全文
posted @ 2019-03-08 20:51 Veritas_des_Liberty 阅读(260) 评论(0) 推荐(0)
摘要:Given several boxes with different colors represented by different positive numbers. You may experience several rounds to remove boxes until there is 阅读全文
posted @ 2019-03-07 22:08 Veritas_des_Liberty 阅读(345) 评论(0) 推荐(0)
摘要:Given a list of non-negative numbers and a target integer k, write a function to check if the array has a continuous subarray of size at least 2 that 阅读全文
posted @ 2019-03-07 20:56 Veritas_des_Liberty 阅读(222) 评论(0) 推荐(0)