2016-09-1921:01:50,123:WARNING:certbot.renewal:Attempting torenew cert from/etc/letsencrypt/renewal/llonely.com.confproduced an unexpected error:The manual plugin isnotworking;there may be problems with your existing configuration.
The error was:PluginError('Running manual mode non-interactively is not supported',).Skipping.
Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number.
The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Please note that your returned answers (both index1 and index2) are not zero-based.
You may assume that each input would have exactly one solution.
上周突然从某一天开始,右键菜单中的 Open with Sublime Text 突然出现了这个问题,Sublime Text 本身可以正常使用,但是用右键菜单中的 Open with Sublime Text 来打开文件的话,就会弹出“此应用无法在你的电脑上运行”这一提示。不得不事先将 Sublime Text 打开,然后将所需编辑的文件拖入打开……煞是令人苦恼。
搜索也未能发现解决方案,似乎只有在知乎上有人问过这个问题,但没有解决方案,也没有相关的英文搜索结果……更新至 Build 3114 ,并尝试重装 Sublime Text 后,也没有解决。
无奈下,在注册表中查看了一下 Open with Sublime Text 的键值,在这里发现了问题。
该键值位于
HKEY_CLASSES_ROOT\*\shell\Open with Sublime Text\command ,举个我的例子,默认安装情况下的值为
D:\Program Files\Sublime Text3\sublime_text.exe"%1" ,考虑到可能是空格的问题(顺便参考了一下 Atom 的右键菜单键值),加引号修改为
"D:\Program Files\Sublime Text 3\sublime_text.exe""%1" 后工作正常。
上述思路不完全正确。
考虑到之前没有出现这个问题,发现情况与 Unquoted Service Paths 现象有点相像,然后我在 D 盘目录下发现了一个名为’Program’的文件,打开后发现是某 license manager 的日志文件,问题就这么解决了。(2333 这个软件没有处理好路径中的空格……)
以 D:\Program Files\Sublime Text 3\sublime_text.exe 为例,windows 默认的解析方式是
Given a non negative integer number num. For every numbers i in the range 0 ≤ i ≤ num calculate the number of 1’s in their binary representation and return them as an array.
Example:
For
num=5 you should return
[0,1,1,2,1,2].
Follow up:
It is very easy to come up with a solution with run time O(n*sizeof(integer)). But can you do it in linear time O(n) /possibly in a single pass?
Space complexity should be O(n).
Can you do it like a boss? Do it without using any builtin function like __builtin_popcount in c++ or in any other language.
Hint:
You should make use of what you have produced already.
Divide the numbers in ranges like [2-3], [4-7], [8-15] and so on. And try to generate new range from previous.
Or does the odd/even status of the number help you in calculating the number of 1s?
一开始没看 Hint ,看到题目的要求下意识的想到了树状数组中 lowbit 的用法,但是感觉这样还是不能满足 O(N) 的时间要求……
思路大体是这样的,首先从 num 开始计算出 1 的个数,然后通过形似 num-=(num&-num) 的运算消去最后一个 1 ,完成对下一个 num 的计数,然后依次类推。之后从 num 递减,若出现了未记录的数,则继续如上的计算。
代码如下:
C
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* Return an array of size *returnSize.
* Note: The returned array must be malloced, assume caller calls free().