随笔分类 -  动态规划

摘要:Given s1, s2, s3, find whether s3 is formed by the interleaving of s1 and s2. Example 1: Example 2: 题意 给出s1,s2,s3,判断是否能从s3中抽取出若干个字符以原顺序组成字符串和s1相等,并且s3 阅读全文
posted @ 2019-02-27 20:15 TobicYAL 阅读(167) 评论(0) 推荐(0)
摘要:A message containing letters from A-Z is being encoded to numbers using the following mapping: Given a non-empty string containing only digits, determ 阅读全文
posted @ 2019-02-23 19:16 TobicYAL 阅读(176) 评论(0) 推荐(0)
摘要:Given a string s1, we may represent it as a binary tree by partitioning it to two non-empty substrings recursively. Below is one possible representati 阅读全文
posted @ 2019-02-23 10:57 TobicYAL 阅读(205) 评论(0) 推荐(0)
摘要:Given two words word1 and word2, find the minimum number of operations required to convert word1 to word2. You have the following 3 operations permitt 阅读全文
posted @ 2019-02-13 19:40 TobicYAL 阅读(151) 评论(0) 推荐(0)
摘要:You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you cl 阅读全文
posted @ 2019-02-12 22:11 TobicYAL 阅读(146) 评论(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-02-11 11:14 TobicYAL 阅读(185) 评论(0) 推荐(0)
摘要:Given an input string (s) and a pattern (p), implement wildcard pattern matching with support for '?' and '*'. The matching should cover the entire in 阅读全文
posted @ 2019-02-04 14:55 TobicYAL 阅读(228) 评论(0) 推荐(0)
摘要:Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'. The matching should cover the entire  阅读全文
posted @ 2019-01-25 13:35 TobicYAL 阅读(258) 评论(0) 推荐(0)
摘要:题目描述 Farmer John has noticed that his cows often move between nearby fields. Taking this into account, he wants to plant enough grass in each of his f 阅读全文
posted @ 2018-12-22 11:13 TobicYAL 阅读(178) 评论(0) 推荐(0)
摘要:描述 After going through the receipts from your car trip through Europe this summer, you realised that the gas prices varied between the cities you visi 阅读全文
posted @ 2018-12-20 17:35 TobicYAL 阅读(386) 评论(0) 推荐(0)
摘要:描述 奶牛们打算通过锻炼来培养自己的运动细胞,作为其中的一员,贝茜选择的运动方式是每天进行N(1 <= N <= 10,000)分钟的晨跑。在每分钟的开始,贝茜会选择下一分钟是用来跑步还是休息。 贝茜的体力限制了她跑步的距离。更具体地,如果贝茜选择在第i分钟内跑步,她可以在这一分钟内跑D_i(1 < 阅读全文
posted @ 2018-12-20 12:04 TobicYAL 阅读(296) 评论(0) 推荐(0)
摘要:描述 Biologists finally invent techniques of repairing DNA that contains segments causing kinds of inherited diseases. For the sake of simplicity, a DNA 阅读全文
posted @ 2018-10-29 23:26 TobicYAL 阅读(449) 评论(0) 推荐(0)
摘要:题目描述 今年是国际数学联盟确定的“ 2000 ――世界数学年”,又恰逢我国著名数学家华罗庚先生诞辰 9090 周年。在华罗庚先生的家乡江苏金坛,组织了一场别开生面的数学智力竞赛的活动,你的一个好朋友 XZ 也有幸得以参加。活动中,主持人给所有参加活动的选手出了这样一道题目: 设有一个长度为 N 的 阅读全文
posted @ 2018-08-02 16:45 TobicYAL 阅读(245) 评论(0) 推荐(0)
摘要:题目描述 小渊和小轩是好朋友也是同班同学,他们在一起总有谈不完的话题。一次素质拓展活动中,班上同学安排做成一个 mm 行 nn 列的矩阵,而小渊和小轩被安排在矩阵对角线的两端,因此,他们就无法直接交谈了。幸运的是,他们可以通过传纸条来进行交流。纸条要经由许多同学传到对方手里,小渊坐在矩阵的左上角,坐 阅读全文
posted @ 2018-07-27 23:04 TobicYAL 阅读(161) 评论(0) 推荐(0)
摘要:题目描述 帅帅经常跟同学玩一个矩阵取数游戏:对于一个给定的 n \times mn×m 的矩阵,矩阵中的每个元素 a_{i,j}ai,j​ 均为非负整数。游戏规则如下: 帅帅想请你帮忙写一个程序,对于任意矩阵,可以求出取数后的最大得分。 输入输出格式 输入格式: 输入文件包括 n+1n+1 行: 第 阅读全文
posted @ 2018-07-27 17:42 TobicYAL 阅读(262) 评论(0) 推荐(0)
摘要:题目描述 设有 N \times NN×N 的方格图 (N \le 9)(N≤9) ,我们将其中的某些方格中填入正整数,而其他的方格中则放入数字 00 。如下图所示(见样例): 某人从图的左上角的 AA 点出发,可以向下行走,也可以向右走,直到到达右下角的 BB 点。在走过的路上,他可以取走方格中的 阅读全文
posted @ 2018-07-01 17:18 TobicYAL 阅读(213) 评论(0) 推荐(0)
摘要:题目描述 棋盘上 AA 点有一个过河卒,需要走到目标 BB 点。卒行走的规则:可以向下、或者向右。同时在棋盘上 CC 点有一个对方的马,该马所在的点和所有跳跃一步可达的点称为对方马的控制点。因此称之为“马拦过河卒”。 棋盘用坐标表示, AA 点 (0, 0)(0,0) 、 BB 点 (n, m)(n 阅读全文
posted @ 2018-07-01 09:48 TobicYAL 阅读(185) 评论(0) 推荐(0)
摘要:描述 Consider an arbitrary sequence of integers. One can place + or - operators between integers in the sequence, thus deriving different arithmetical e 阅读全文
posted @ 2018-06-30 15:08 TobicYAL 阅读(209) 评论(0) 推荐(0)
摘要:描述 北大信息学院的同学小明毕业之后打算创业开餐馆.现在共有n 个地点可供选择。小明打算从中选择合适的位置开设一些餐馆。这 n 个地点排列在同一条直线上。我们用一个整数序列m1, m2, ... mn 来表示他们的相对位置。由于地段关系,开餐馆的利润会有所不同。我们用pi 表示在mi 处开餐馆的利润 阅读全文
posted @ 2018-06-30 14:55 TobicYAL 阅读(501) 评论(0) 推荐(0)
摘要:描述 怪盗基德是一个充满传奇色彩的怪盗,专门以珠宝为目标的超级盗窃犯。而他最为突出的地方,就是他每次都能逃脱中村警部的重重围堵,而这也很大程度上是多亏了他随身携带的便于操作的滑翔翼。 有一天,怪盗基德像往常一样偷走了一颗珍贵的钻石,不料却被柯南小朋友识破了伪装,而他的滑翔翼的动力装置也被柯南踢出的足 阅读全文
posted @ 2018-06-27 14:39 TobicYAL 阅读(630) 评论(0) 推荐(0)