1 | """ |
string to integer / atoi
1 | """ |
powx-n
1 | class Solution(object): |
reverse integer
1 | """ |
longest substring without repeating characters
“””
https://leetcode-cn.com/problems/longest-substring-without-repeating-characters/description/
无重复字符的最长子串
“””
class Solution(object):
def lengthOfLongestSubstring(self, s):
“””
:type s: str
:rtype: int
>>> s = Solution()
>>> s.lengthOfLongestSubstring(“aab”)
2
>>> s.lengthOfLongestSubstring(“dvdf”)
3
>>> s.lengthOfLongestSubstring(“abcabcbb”)
3
>>> s.lengthOfLongestSubstring(“abcabcbb”)
3
>>> s.lengthOfLongestSubstring(“abba”)
2
>>> s.lengthOfLongestSubstring(“aaaaaaa”)
1
>>> s.lengthOfLongestSubstring(“a”)
1
>>> s.lengthOfLongestSubstring(“”)
0
“””
if s == “”:
return 0
if len(s) == 1:
return 1
# 记录字符到index的映射
dic = {}
L, start_ind = 0, 0
for idx, i in enumerate(s):
# 第idx个字符在dic中且是超过start_ind的字符
if i in dic and start_ind <= dic[i]:
L = max(idx - start_ind, L)
start_ind = dic[i] + 1
dic[i] = idx
L = max(idx + 1 - start_ind, L)
return L
add two numbers
1 | """ |
two sum
1 | """ |
max sub-array problem
1 |
|
ubuntu桌面版屏保screensaver
1 | sudo apt-get install xscreensaver xscreensaver-gl-extra xscreensaver-data-extra |
- Atlantis
- boxed
- FadePlot
- FlipFlop
- GLMatrix
- Grav
- Juggler3D
- Pacman
- Rubik
锁屏进入屏保1
xscreensaver-command -lock
或者自带的屏保gnome-screensaver
python: collections.ChainMap
1 | # python3 |