Dynamic Programing about String

对于两个字符串之间的关系,有很多题目可以用动态规划的思想解答。关键是要找到两个字符串之间的状态转移方程。此处可以使用一个二维矩阵,找出两个字符串的前缀之间的关系,从而推出两个字符串之间的关系。

LeetCode Database

这次的两个题目涉及比较关系,mysql中求取某一属性的最大值,可以使用聚合函数max()。如果求第二大值,可以求取小于最大值的最大值。如果是第三大、第四大甚至第五大值之时,就不能像这样循环地定义。下面这道题给出了一个不同的思路。

Largest Number

题目

给定一个非负整数的列表,将它们排序之后首尾相连得到一个整数,返回可得的最大整数

Example 1:

Input: [10,2]
Output: “210”

Example 2:

Input: [3,30,34,5,9]
Output: “9534330”

Hello World

Welcome to Hexo! This is your very first post. Check documentation for more info. If you get any problems when using Hexo, you can find the answer in troubleshooting or you can ask me on GitHub.

Your browser is out-of-date!

Update your browser to view this website correctly. Update my browser now

×