Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain only lower case letters. If no such two words exist, return 0.
Example 1:
Input: ["abcw","baz","foo","bar","xtfn","abcdef"]
Output: 16 Explanation: The two words can be "abcw", "xtfn".
Example 2:
Input: ["a","ab","abc","d","cd","bcd","abcd"]
Output: 4 Explanation: The two words can be "ab", "cd".
Example 3:
Input: ["a","aa","aaa","aaaa"]
Output: 0 Explanation: No such pair of words.
Given an array of integers where 1 ≤ a[i] ≤ n (n = size of array), some elements appear twice and others appear once.
Find all the elements of [1, n] inclusive that do not appear in this array.
Could you do it without extra space and in O(n) runtime? You may assume the returned list does not count as extra space.
Example:
You are climbing a stair case. It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Note: Given n will be a positive integer.
class Solution(object):
def c(self, m, n):
x = 1
for i in xrange(m-n+1, m+1):
x *= i
for i in xrange(2, n+1):
x /= i
return x
def climbStairs(self, n):
"""
:type n: int
:rtype: int
"""
result = 0
for i in range(0, n/2+1):
result += self.c(n-i, i)
return result
我们知道,图片上的每一个像素点都是由(r, g, b)三个颜色通道组成的,轻微的改动其中的像素值肉眼并无法察觉。利用这一点,我们就可以在图片中隐写大量的信息。
在the First Lady of the Internet的图片中,三个通道都隐写了信息,我们可以通过python的Pillow库进行图片处理,从而得到隐写的内容。
BTW, 女神原图有福利 (~.~)
from PIL import Image
import matplotlib.pyplot as plt
img = Image.open('1.png')
pix = img.load()
for i in range(img.size[0]):
for j in range(img.size[1]):
(r, g, b) = pix[i, j]
pix[i, j] = (0, 0, r%2*255)
img.show()