Given a string s which consists of lowercase or uppercase letters, return the length of the longest palindrome that can be built with those letters. Letters are case sensitive, for example, “Aa” is not considered a palindrome here.
思路 首先学习一个新单…
Python里读取txt文件的方法有很多,但numpy读取字符串比较困难,这时可以考虑使用csv库,读取txt文件中的每一行文本。
代码
data []
with open(*******.txt, rt) as csvfile:reader csv.reader(csvfile, delimiter,)for row in reader:data…
Given an integer numRows, return the first numRows of Pascal’s triangle. In Pascal’s triangle, each number is the sum of the two numbers directly above it as shown:
前几天做的动态规划题好难呜呜,做道水题找回自信~
状态转移方程 triangle[i][j] …
Given a non-empty array nums containing only positive integers, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.
思路 这道题假如能看出是一道0-1背包问题的话,就很好解决了。题目说需要划分…