欢迎来到PJCK的博客

随笔分类 -  数据结构与算法----动态规划

线性DP 背包 数字三角形
摘要:Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1's in their binary representation and r 阅读全文
posted @ 2019-05-14 22:33 PJCK 阅读(146) 评论(0) 推荐(0)
摘要:Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum pro 阅读全文
posted @ 2019-05-14 21:51 PJCK 阅读(89) 评论(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-05-10 21:15 PJCK 阅读(113) 评论(0) 推荐(0)
摘要:Given an unsorted array of integers, find the length of longest increasing subsequence. Example: Note: There may be more than one LIS combination, it 阅读全文
posted @ 2019-05-10 21:01 PJCK 阅读(127) 评论(0) 推荐(0)
摘要:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the fo 阅读全文
posted @ 2019-05-10 19:19 PJCK 阅读(109) 评论(0) 推荐(0)
摘要:Given an integer array nums, find the contiguous subarray within an array (containing at least one number) which has the largest product. Example 1: E 阅读全文
posted @ 2019-05-10 19:03 PJCK 阅读(106) 评论(0) 推荐(0)
摘要:Given a 2D binary matrix filled with 0's and 1's, find the largest square containing only 1's and return its area. Example: 这是一个DP题,好像是线性DP吧。 官方题解有DP的 阅读全文
posted @ 2019-05-10 12:30 PJCK 阅读(151) 评论(0) 推荐(0)
摘要:Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path. 阅读全文
posted @ 2019-05-10 09:39 PJCK 阅读(114) 评论(0) 推荐(0)
摘要:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2019-05-10 09:35 PJCK 阅读(109) 评论(0) 推荐(0)
摘要:A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any p 阅读全文
posted @ 2019-05-10 09:31 PJCK 阅读(145) 评论(0) 推荐(0)
摘要:You are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping yo 阅读全文
posted @ 2019-05-09 19:57 PJCK 阅读(165) 评论(0) 推荐(0)
摘要:Say you have an array for which the ith element is the price of a given stock on day i. If you were only permitted to complete at most one transaction 阅读全文
posted @ 2019-05-06 20:37 PJCK 阅读(178) 评论(0) 推荐(0)
摘要:输入一个字符串Str,输出Str里最长回文子串的长度。 回文串:指aba、abba、cccbccc、aaaa这种左右对称的字符串。 串的子串:一个串的子串指此(字符)串中连续的一部分字符构成的子(字符)串例如 abc 这个串的子串:空串、a、b、c、ab、ac、bc、abc 收起 输入一个字符串St 阅读全文
posted @ 2019-04-15 17:58 PJCK 阅读(186) 评论(0) 推荐(0)
摘要:题目描述: 我们经常会听说DNA亲子鉴定是怎么回事呢?人类的DNA由4个基本字母{A,C,G,T}构成,包含了多达30亿个字符。如果两个人的DNA序列相差0.1%,仍然意味着有300万个位置不同,所以我们通常看到的DNA亲子鉴定报告上结论有:相似度99.99%,不排除亲子关系。 怎么判断两个基因的相 阅读全文
posted @ 2019-04-04 15:48 PJCK 阅读(197) 评论(0) 推荐(0)
摘要:题目描述 有一个箱子容量为VV(正整数,0≤V≤20000),同时有nn个物品(0<n≤30,每个物品有一个体积(正整数)。 要求nn个物品中,任取若干个装入箱内,使箱子的剩余空间为最小。 输入输出格式 输入格式: 11个整数,表示箱子容量 11个整数,表示有nn个物品 接下来nn行,分别表示这nn 阅读全文
posted @ 2019-03-20 17:17 PJCK 阅读(275) 评论(0) 推荐(0)
摘要:题目描述 NN位同学站成一排,音乐老师要请其中的(N-KN−K)位同学出列,使得剩下的KK位同学排成合唱队形。 合唱队形是指这样的一种队形:设K位同学从左到右依次编号为1,2,…,K1,2,…,K,他们的身高分别为T_1,T_2,…,T_KT1​,T2​,…,TK​, 则他们的身高满足T_1<... 阅读全文
posted @ 2019-03-20 15:17 PJCK 阅读(281) 评论(0) 推荐(0)
摘要:题目描述 给出一段序列,选出其中连续且非空的一段使得这段和最大。 输入输出格式 输入格式: 第一行是一个正整数NN,表示了序列的长度。 第二行包含NN个绝对值不大于1000010000的整数A_iAi​,描述了这段序列。 输出格式: 一个整数,为最大的子段和是多少。子段的最小长度为11。 输入输出样 阅读全文
posted @ 2019-03-19 14:34 PJCK 阅读(314) 评论(0) 推荐(0)
摘要:The Triangle Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 59698 Accepted: 35792 Description 73 88 1 02 7 4 44 5 2 6 5(Figure 1) Figure 1 阅读全文
posted @ 2019-03-12 13:17 PJCK 阅读(159) 评论(0) 推荐(0)
摘要:To the Max Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 54338 Accepted: 28752 Description Given a two-dimensional array of positive and 阅读全文
posted @ 2019-03-11 20:44 PJCK 阅读(140) 评论(0) 推荐(0)
摘要:Max Sequence Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 18511 Accepted: 7743 Description Give you N integers a1, a2 ... aN (|ai| <=100 阅读全文
posted @ 2019-03-11 18:48 PJCK 阅读(284) 评论(0) 推荐(1)