g = lambda x:x+1
lambda作为一个表达式,定义了一个匿名函数,上例的代码x为入口参数,x+1为函数体,用函数来表示为:
def g(x):
return x+1
安装了Ubuntu后分辨率和显示器不匹配
xrandr Failed to get size of gamma for output default
sudo vim /etc/xorg.conf
复制以下内容:
Section "Monitor"
Identifier "Monitor0"
VendorName "Monitor Vendor"
ModelName "Monitor Model"
HorizSync 28.0 - 70.0
VertRefresh 56.0 - 75.0
EndSection
Section "Device"
Identifier "VMware SVGA"
Driver "vesa"
EndSection
Section "Screen"
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
SubSection "Display"
Viewport 0 0
Depth 24
Modes "1920x1080_60.00"
EndSubSection
EndSection
:wq!(保存
重新启动就成功了。
#Binary Search Too big, go left Too small, go right Equal, found
find 8
mid mid 1 3 5 6 8 9 13 15 18 23 26 28
public static int binarySearch(int a[], int key)
{
int lo = 0, hi = a.length-1;
while(lo <= hi)
{
int mid = lo+(hi-lo)/2;
if (key<a[mid]) hi = mid-1;
else if (key>a[mid]) lo = mid+1;
else return mid;
}
return -1;
}
How many array accesses does the following code fragment make as a function of nn? (Assume the compiler does not optimize away any array accesses in the innermost loop.)
int sum = 0;
for (int i = 0; i < n; i++)
for (int j = i+1; j < n; j++)
for (int k = 1; k < n; k = k*2)
if (a[i] + a[j] >= a[k]) sum++;
∼3n^2 ~3n^2lgn/2 ~3n^3/2 ~3n^3
Not all triple loops have cubic running times. For a given value of ii and jj, the kk-loop requires only 3lgn array access: the body is executed lgn times and each time involves 3 array accesses. As in the 2-SUM and 3-SUM analysis, the number of times the k-loop is executed is nC2 ~ n^2/2
本文为leetcode刷题笔记。
在网上搜了博客的网站,最后还是决定看教程,用github搭一个静态博客,现在是第一条测试博客。