This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 从后往前算 == 从前往后算(当数字位数是偶数 或者 0) 或者 从后往前算/10 == 从前往后算(当数字位数是奇数) | |
*/ | |
bool isPalindrome(int x) { | |
if(x < 0 || (x != 0 && x % 10 == 0)) return false; | |
int sum = 0; | |
while(x > sum) { | |
sum = sum*10 + (x % 10); | |
x = x / 10; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
计算汉明距离, | |
eg:x = 4,y = 3 | |
x:0100 | |
y:0011 | |
汉明距离 = 3 | |
算法: | |
先算x^y = 0111 | |
这里只需要判断有几个1,那么汉明距离就是多少 | |
技巧 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*递归版本 | |
*/ | |
int getSum(int a, int b) { | |
return b == 0 ? a : getSum(a^b, (a&b)<<1); | |
} | |
/*不递归版本 | |
int getSum(int a, int b) { | |
int sum = a; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
char findTheDifference(char* s, char* t) { | |
int s_sum = 0; | |
int t_sum = 0; | |
while(*s != '\0') { | |
s_sum += *s; | |
s++; | |
} | |
while(*t != '\0') { | |
t_sum += *t; | |
t++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getHead($urls){ | |
$results = array(); | |
// make sure the rolling window isn't greater than the # of urls | |
$rolling_window = 5; | |
$rolling_window = (sizeof($urls) < $rolling_window) ? sizeof($urls) : $rolling_window; | |
$master = curl_multi_init(); | |
// $curl_arr = array(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 将设置放入此文件中以覆盖默认设置 | |
{ | |
"editor.fontSize": 16, | |
"terminal.integrated.shell.linux": "/bin/zsh", | |
"editor.tabSize": 2, | |
"window.zoomLevel": 0, | |
"editor.minimap.enabled": true, | |
"workbench.iconTheme": "vs-seti", | |
"phpformatter.composer": true, | |
"[cpp]": { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# set Zsh as your default Tmux shell | |
set-option -g default-shell /bin/zsh | |
# UTF is great, let us use that | |
set -g utf8 | |
set-window-option -g utf8 on | |
# Tmux should be pretty, we need 256 color for that | |
#set -g default-terminal "screen-256color" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// _oo0oo_ | |
// o8888888o | |
// 88" . "88 | |
// (| -_- |) | |
// 0\ = /0 | |
// ___/`---'\___ | |
// .' \\| |// '. | |
// / \\||| : |||// \ | |
// / _||||| -:- |||||- \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Plugins will be downloaded under the specified directory. | |
call plug#begin('~/.vim/plugged') | |
" Declare the list of plugins. | |
Plug 'tpope/vim-sensible' | |
Plug 'junegunn/seoul256.vim' | |
Plug 'https://github.com/vim-scripts/fcitx.vim.git' | |
Plug 'posva/vim-vue' |