标签:: 编程题

0

leetcode - 647. Palindromic Substrings

Given a string, your task is to count how many palindromic substrings in this string. The substrings with different start indexes or end indexes are counted as different substrings even they consist

0

多出的数字

问题:在两个输入的数组中除了一个数字之外其余数字的值和顺序都相同,第一个数组比第二个数组多一个数字。请问如何找出第一个数组中多出的数字的下标?例如如果输入两个数组{2, 4, 6, 8, 9, 10, 12}和{2, 4, 6, 8, 10, 12},则输出4,该下标对应的数字是9。 方法一:对数组进行遍历比较 方法二:使用二分法 1234567891011121314151617181920

0

台阶问题/斐波那契

台阶问题一只青蛙一次可以跳上1级台阶,也可以跳上2级。求该青蛙跳上一个n级的台阶总共有多少种跳法。 12# 递归,简洁,但是有大量的重复计算,效率低fib = lambda n: n if n <= 2 else fib(n - 1) + fib(n - 2) 1234567891011121314def memo(func): cache = {} de