Leetcode 9-12

No. 9 Palindrome Number (简单,PASS)


No. 10 Regular Expression Matching (HARD)

https://leetcode.com/problems/regular-expression-matching/discuss/5723/My-DP-approach-in-Python-with-comments-and-unittest


No. 11 Container With Most Water

注意点:本题目并不是求已给出的height中符合要求的sum最大,而是给出最大能盛水的量。

Solution: Two Pointers

Note: The most water = width * min(left, right), where width = j - i, i and j are the indexes of two sides.


No. 12 Integer to Roman

将整数转换成罗马数字(Roman),字符表对应如下:

其中,有六种特殊情况,如下:

Solution:不断整除,分母分别为[1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]。

猜你喜欢

转载自www.cnblogs.com/kedongh/p/10951300.html