摘要: 0、求回文数 回数是指从左向右读和从右向左读都是一样的数,例如12321,909。请利用filter()筛选出回数: # 测试: 1、案例解释 a='python'b=a[::-1]print(b) #nohtypc=a[::-2]print(c) #nhy#从后往前数的话,最后一个位置为-1d=a 阅读全文
posted @ 2019-03-28 21:45 Archer-Fang 阅读(549) 评论(0) 推荐(0) 编辑
摘要: 求结点对之间有负数的距离。限制条件:不允许有包含负权值的边组成的回路。 例子: 1.初始化 其中distance矩阵表示i,j两结点之间的距离。 path矩阵,以第一行为例,表示0->0值为n表示不可达,0->1值为0表示可由0到1. 2.i,j两结点经过0结点的情况 以此类推。 代码: 阅读全文
posted @ 2019-03-23 16:55 Archer-Fang 阅读(237) 评论(0) 推荐(0) 编辑
摘要: Maximum subarray problem The maximum subarray problem is the task of finding the contiguous subarray within a one-dimensional array, a[1...n], of numb 阅读全文
posted @ 2019-03-19 13:30 Archer-Fang 阅读(167) 评论(0) 推荐(0) 编辑
摘要: Integer Partition In number theory and combinatorics, a partition of a positive integer n, also called an integer partition, is a way of writing nas a 阅读全文
posted @ 2019-03-19 12:26 Archer-Fang 阅读(648) 评论(0) 推荐(0) 编辑
摘要: 中文理解: 0-1背包问题:有一个贼在偷窃一家商店时,发现有n件物品,第i件物品价值vi元,重wi磅,此处vi与wi都是整数。他希望带走的东西越值钱越好,但他的背包中至多只能装下W磅的东西,W为一整数。应该带走哪几样东西?这个问题之所以称为0-1背包,是因为每件物品或被带走;或被留下;小偷不能只带走 阅读全文
posted @ 2019-03-19 11:36 Archer-Fang 阅读(1228) 评论(0) 推荐(0) 编辑
摘要: Longest Increasing Subsequence The longest increasing subsequence problem is to find a subsequence of a given sequence in which the subsequence's elem 阅读全文
posted @ 2019-03-19 10:59 Archer-Fang 阅读(165) 评论(0) 推荐(0) 编辑
摘要: Levenshtein Distance The Levenshtein distance is a string metric for measuring the difference between two sequences. Informally, the Levenshtein dista 阅读全文
posted @ 2019-03-18 12:31 Archer-Fang 阅读(267) 评论(0) 推荐(0) 编辑
摘要: Longest common subsequence problem The longest common subsequence (LCS) problem is the problem of finding the longest subsequence common to all sequen 阅读全文
posted @ 2019-03-18 11:31 Archer-Fang 阅读(224) 评论(0) 推荐(0) 编辑
摘要: Staircase Problem There are n stairs, a person standing at the bottom wants to reach the top. The person can climb either 1 or 2 stairs at a time. Cou 阅读全文
posted @ 2019-03-18 11:04 Archer-Fang 阅读(200) 评论(0) 推荐(0) 编辑
摘要: Rain Terraces (Trapping Rain Water) Problem Given an array of non-negative integers representing terraces in an elevation map where the width of each 阅读全文
posted @ 2019-03-15 11:51 Archer-Fang 阅读(198) 评论(0) 推荐(0) 编辑