博主昨天把blog迁移到digitalocean啦~特地来个傻瓜式配置教程。
本文包括如下内容
- centos下安装wordpress过程
- 开启mod_rewrite模块
- 开启GZIP压缩网页
- 上传图片/文件失败解决办法
- YOAST SEO sitemap 404 解决办法
博主昨天把blog迁移到digitalocean啦~特地来个傻瓜式配置教程。
本文包括如下内容
leetcode Bulb Switcher
There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or turning off if it's on). For the _n_th round, you only toggle the last bulb. Find how many bulbs are on after n rounds.
Example:
Given n = 3.
At first, the three bulbs are [off, off, off].
After first round, the three bulbs are [on, on, on].
After second round, the three bulbs are [on, off, on].
After third round, the three bulbs are [on, off, off].
So you should return 1, because there is only one bulb is on.
本文记录本博客SEO的一些优化方法。不定期更新。
leetcode Maximum Product of Word Lengths
Given a string array
words
, find the maximum value oflength(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:
Given
["abcw", "baz", "foo", "bar", "xtfn", "abcdef"]
Return16
The two words can be"abcw", "xtfn"
.Example 2:
Given
["a", "ab", "abc", "d", "cd", "bcd", "abcd"]
Return4
The two words can be"ab", "cd"
.Example 3:
Given
["a", "aa", "aaa", "aaaa"]
Return0
No such pair of words.Follow up: Could you do better than O(_n_2), where n is the number of words?
前言:
当数据量大的时候,一台机器可能不足以满足性能的需求,如存储空间、内存不足,而垂直扩展十分昂贵,故用分片进行水平扩展是一个很好的解决方法。
本文介绍了mongodb 进行分片的方法和步骤
Given an Iterator class interface with methods:
next()
andhasNext()
, design and implement a PeekingIterator that support thepeek()
operation -- it essentially peek() at the element that will be returned by the next call to next()Here is an example. Assume that the iterator is initialized to the beginning of the list:
[1, 2, 3]
.Call
next()
gets you 1, the first element in the list.Now you call
peek()
and it returns 2, the next element. Callingnext()
after that still return 2.You call
next()
the final time and it returns 3, the last element. CallinghasNext()
after that should return false.Hint:
- Think of "looking ahead". You want to cache the next element.
- Is one variable sufficient? Why or why not?
- Test your design with call order of
peek()
beforenext()
vsnext()
beforepeek()
.- For a clean implementation, check out Google's guava library source code.
Follow up: How would you extend your design to be generic and work with all types, not just integer?
leetcode Remove Duplicate Letters
Given a string which contains only lowercase letters, remove duplicate letters so that every letter appear once and only once. You must make sure your result is the smallest in lexicographical order among all possible results.
Example:
Given
"bcabc"
Return"abc"
Given
"cbacdcbc"
Return"acdb"
本文简单介绍Binary indexed tree (Fenwick tree)