tmp

如何实现一个高效的单向链表逆序输出

你说的曾经没有我的故事 提交于 2019-11-27 16:19:25
下面是其中一种写法,也可以有不同的写法,比如递归等。供参考。 static class Node { private int data ; private Node next ; Node ( int d ) { data = d ; next = null ; } public int getData ( ) { return data ; } public void setData ( int data ) { this . data = data ; } public Node getNext ( ) { return next ; } public void setNext ( Node next ) { this . next = next ; } } public static void reverse ( Node head ) { if ( null == head || null == head . getNext ( ) ) { return ; } Node prev = null ; Node pcur = head . getNext ( ) ; Node next ; while ( pcur != null ) { if ( pcur . getNext ( ) == null ) { pcur . setNext ( prev ) ; break ;

python字符串和循环语句小测试

可紊 提交于 2019-11-27 15:55:55
1,用pip安装ipython 1,解决依赖 yum install openssl-devel zlib-devel bzip2-devel expat-devel gdbm-devel tk-devel tcl-devel readline-devel sqlite-devel libX11-devel libX11 tkinter gcc gcc-c++ epel-release 2,安装python36并且在/opt/下做一个虚拟目录 yum -y install python36 cd /opt/ python36 -m venv py3 3,进入虚拟目录 source /opt/py3/bin/activate 4,用pip安装ipython pip install ipython 5,可能会需要更新pip pip install --upgrade pip 2,tmpstr=‘18801118888-Shanghai’取出‘-‘ 分隔的最后一部分,并且将其倒叙重复第二遍,变成大写并且以40个字符的宽度居中显示出来。同时,输出十进制123的二进制,八进制和十六进制的值 tmpstr='18801118888-Shanghai' a=tmpstr.split('-')[1] print(a) i=1 while i<3: print(a[::-1]) i=i+1 a=a

字符串的排列

倖福魔咒の 提交于 2019-11-27 15:24:21
class Solution { public: vector<string> Fun(string input){ vector<string> tmp; // tmp.insert(tmp.end(), input.begin(), input.end()); tmp.push_back(input); if(idx >= input.length()-1) return tmp; int k = 0; while(k < 1){ idx ++; vector<string> tmp_out = Fun(input); //tmp.insert(tmp.end(), tmp_out.begin(), tmp_out.end()); tmp = tmp_out; idx --; string str = input; for(int i = idx; i < idx +1; i++){ for(int j = i +1; j < str.length(); j++){ if(str[i] != str[j]){ char center; center = str[i]; str[i] = str[j]; str[j] = center; //tmp.push_back(str); idx++; vector<string> in_tmp = Fun(str); tmp

清理回收站和恢复数据

不想你离开。 提交于 2019-11-27 15:08:44
查看文件块数命令:hdfs fsck / -blocks HDFS垃圾回收站, 默认是0,单位是分钟,实验设置为1天即1440. core-site.xml <property> <name>fs.trash.interval</name> <value>1440</value> </property> 在线上把垃圾回收站的时间调大到7天 定时执行脚本,shell开发删除回收站 清理垃圾回收站: hdfs dfs -ls /user/root/.Trash hdfs dfs -rm -r /user/root/.Trash/190815070000 恢复数据: 实验: #删除一个文件夹 [root@oldboy-node101 ~]# hdfs dfs -rm -r /tmp/logs/root/logs/logs 19/06/17 20:29:08 INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 1440 minutes, Emptier interval = 0 minutes. Moved: 'hdfs://oldboy-node101:9000/tmp/logs/root/logs/logs' to trash at: hdfs://oldboy-node101

【01字典树】hdu-5536 Chip Factory

只谈情不闲聊 提交于 2019-11-27 14:09:08
【题目链接】 http://acm.hdu.edu.cn/showproblem.php?pid=5536 【题意】 求一个式子,给出一组数,其中拿出ai,aj,ak三个数,使得Max{ (ai+aj) ^ ak } 【题解】 其实这里就需要大家做一个删除的操作; 类似于dfs的恢复现场的操作即可。 【代码】 1 #include<cstdio> 2 #include<cstring> 3 #include<algorithm> 4 using namespace std; 5 const int N = 1e5+10; 6 int Son[N*31][2]; 7 int a[N],idx; 8 int Cnt[N*31]; 9 void Insert( int x ){ 10 int p = 0 ; 11 for(int i=30;~i;i--){ 12 int t = x >> i & 1 ; 13 if( !Son[p][t] ){ 14 Son[p][t] = ++idx; 15 } 16 p = Son[p][t]; 17 Cnt[p] ++ ; 18 } 19 } 20 void Delete( int x ){ 21 int p = 0 , tmp ; 22 for(int i=30;~i;i--){ 23 int t = x >> i & 1 ; 24 if(

bzoj3163

为君一笑 提交于 2019-11-27 13:58:18
1 #include<iostream> 2 #include<cstdio> 3 #include<cmath> 4 #include<string> 5 #include<cstring> 6 #include<algorithm> 7 #include<iomanip> 8 using namespace std; 9 //f[i][j]:前i个物品占j空间的收益 10 //g[i][j]:后i个物品占j空间的收益 11 namespace Moxing{ 12 const int N=1005; 13 int n,q; 14 struct node{ 15 int a,b,c; 16 }toy[N]; 17 long long f[N][N],g[N][N]; 18 void work(){ 19 for(int i=1,tmp;i<=n;i++){ 20 tmp=toy[i].c; 21 for(int j=1;j<N;j++){ 22 f[i][j]=f[i-1][j]; 23 } 24 for(int j=1;tmp!=0;j<<=1){ 25 j=min(j,tmp); 26 tmp-=j; 27 for(int k=N-1;k>=j*toy[i].a;k--){ 28 f[i][k]=max(f[i][k],f[i][k-j*toy[i].a]+j*toy[i]

Linux中{ }的用法

五迷三道 提交于 2019-11-27 13:11:51
一、生成序列 格式:{#..#},按照ASCII表的顺序进行生成,如{a..c}表示a b c,也可以{c..a}倒叙的形式生成c b a # echo {01..20} 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 # echo {z..a} z y x w v u t s r q p o n m l k j i h g f e d c b a # echo {1..20..2} #可设置步长为2 1 3 5 7 9 11 13 15 17 19 # echo {00000..20..2} 00000 00002 00004 00006 00008 00010 00012 00014 00016 00018 00020 # touch {1..5}.txt #生成文件 # ls 1.txt 2.txt 3.txt 4.txt 5.txt 二、序列展开 格式:{#,#,#}。如{a,b,c}表示a b c # touch {a,c,e,f}.txt # ls a.txt c.txt e.txt f.txt # mkdir -p /tmp/{a1/{a,b},a2} # 生成 /tmp/a1, /tmp/a2, /tmp/a1/a, /tmp/a1/b等四个目录 #tree . ├── a1 │ ├── a │

git fetch 和git pull 的差别

假装没事ソ 提交于 2019-11-27 12:41:05
1、git fetch 相当于是从远程获取最新到本地,不会自动merge,如下指令:  git fetch orgin master //将远程仓库的master分支下载到本地当前branch中  git log -p master ..origin/master //比较本地的master分支和origin/master分支的差别  git merge origin/master //进行合并 也可以用以下指令: git fetch origin master:tmp //从远程仓库master分支获取最新,在本地建立tmp分支 git diff tmp //將當前分支和tmp進行對比 git merge tmp //合并tmp分支到当前分支 2. git pull:相当于是从远程获取最新版本并merge到本地 git pull origin master git pull 相当于从远程获取最新版本并merge到本地 在实际使用中,git fetch更安全一些 转自:https://www.cnblogs.com/qiu-Ann/p/7902855.html 来源: https://www.cnblogs.com/mzdljgz/p/11363368.html

【Git 第7课】 忽略文件

对着背影说爱祢 提交于 2019-11-27 12:21:40
在文件夹中,经常会有些“其他”文件,比如上节课最后提到的,编辑器产生~结尾的备份文件,或者一些临时文件。又可能,某些文件我们只是在本地使用,并不想提交到远程的仓库中被别人看到。但如果我们不跟踪这些文件,Git会一直很执着地提醒我们工作目录中有一些未被跟踪的文件。如果你想清净一点,就可以通过.gitignore文件忽略你不想看到的文件。 要感受一下忽略文件的效果,首先你得有打算忽略的文件,所以我们强行创建一个叫做readme.txt.tmp的文件,假设它是readme.txt产生的临时文件。 git status 看一下效果,同上节课中一样,在untracked files里列出了这个文件: # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # readme.txt.tmp nothing added to commit but untracked files present (use "git add" to track) 然后我们在工作目录中新建一个.gitignore文件,在里面写上一行: *tmp 保存退出,再运行 git status: # On branch master # Untracked files: #

字符串“同素异形体”可以用key-value的unordered_map存储

妖精的绣舞 提交于 2019-11-27 12:09:35
49. Group Anagrams Medium 1896123FavoriteShare Given an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"] , Output: [ ["ate","eat","tea"], ["nat","tan"], ["bat"] ] class Solution { public: vector<vector<string>> groupAnagrams(vector<string>& strs) { vector<vector<string>> result; if (strs.empty()) { return result; } unordered_map<string, vector<string>> hashtable; for (string str : strs) { string tmp = str; sort(tmp.begin(), tmp.end()); hashtable[tmp].push_back(str);//插入一个key为tmp,value为增加str的容器 } for (unordered_map<string, vector<string>>: