- 博客(26)
- 资源 (2)
- 收藏
- 关注
原创 BAT面试算法基础学习笔记
打印二叉树 按层,连同行号打印last:表示正在打印 nlast :遍历所有节点换行的条件为: nlast==last->next;二叉树的序列化和反序列化二叉树转换为文件的记录的过程,称为序列化将文件记录信息转换为二叉树的过程,称为反序列化结束符!#归并排序, 改变有序区间(从1开始)快速排序 {}3堆排序 取出最大值存入数组希尔排序 以距离值 跳跳比桶排序计数排序 身高基数排序 个
2017-01-31 09:33:26 1789
原创 myblog 目录
【 题解 】牛客网 刷题笔记2017年1月19日 nowcoder C++ 练习笔记 2017 网易有道内推 v.2017.1.30codejam:Problem A. Teaching Assistant 【Lniux笔记】my Linux 命令学习笔记 Linux 编译与调试 Linux 文件 操作 v.2016.71.30【算法分析】leetcode 350. Intersectio
2017-01-30 22:33:31 207
原创 poj:Largest Rectangle in a Histogram
OJ题目#include<iostream>#include<stack>#include<cstdio>using namespace std;const int N=int (1e5)+9;int h[N]; // highint n;int main(){ // freopen("in.txt","r",stdin); // freopen("in_out
2017-01-30 21:26:54 215
原创 codejam:Problem A. Teaching Assistant
题目:codejam 2016#include<iostream>#include<stack>#include<cstdio>using namespace std;int main(){ //freopen("a.txt","r",stdin); //freopen("A-large-practice_out.txt","w",stdout); i
2017-01-30 11:06:43 256
原创 algorithm analysis 开坑1
做好一件事要善始善终Union-find data type(API)public class UFUF(int N)void union(int p,int q) // add connection between p and qboolean connected(int p,int q)int find(int p)int count() public static void ma
2017-01-29 22:20:57 327
原创 Linux 孤儿、僵尸、服务进程创建
#include"func.h"// 头文件#include<unistd.h>#include<stdlib.h>#include<fcntl.h>#include<limits.h>#include<sys/types.h>#include<sys/stat.h>#include<stdio.h>#include<string.h>#include<sys/select.h>
2017-01-25 19:57:09 204
原创 leetcode 341. Flatten Nested List Iterator
题目在这class NestedIterator {public: NestedIterator(vector<NestedInteger> &nestedList) { for(int i=nestedList.size()-1;i>=0;--i){ s.push(nestedList[i]); } } int nex
2017-01-25 14:34:06 170
原创 2017 网易有道内推
网易有道内推题题目在牛客网 关于数据解析1.XML 数据结构只有一个根节点,是可以嵌套的 2. JSONObjectWithData:options:error 使用数据缓冲解析 3. writeJSONObject:toStream:options:error 使用流解析 4. XML 解析分为两种:SAX解析和DOM解析 PULL?机器学习比较后验概率p(w|x),哪个类的后验概率大,就
2017-01-23 22:47:32 344
原创 leetcode 随机概率 水塘抽样
https://leetcode.com/problems/linked-list-random-node//** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNode(int x) : val(x), next(NULL) {
2017-01-23 21:54:54 766
原创 Linux 文件符操作
2.3 读写文件fd = open(); write(); // Linux 读int fd;fd=open(argv[1],O_RDWR); if(-1==fd){ perror("open"); return -1;}int ret;ret = read(); // 返回0if(ret<=0){ perror("read");}puts();//
2017-01-23 21:52:57 294
原创 nowcoder C++ 练习笔记
nowcoder 题解字节对齐结构体变量的首地址能够被器最宽基本类型的成员的大小整除结构体每个成员相对于结构体首地址的偏移量都是成员大小的整数倍。结构体的总大小最宽基本类型成员大小的整数倍,如有需要编译器会在最末尾一个成员之后加上填充字节。struct T{ char a; int *d; int b; int c:16; double e;};T
2017-01-22 16:10:52 476
原创 牛客网 Linux
linux nowcoderusermod -| new_name old_name -| 修改名称Orphan Process 孤儿进程 会被init进程接管,不浪费资源在父进程没有调用wait()或者waitpid()情况下退出–僵尸进程,浪费资源fork 计算 fork() i=0 ans= 2 ans=2^i+…+2^i(i>=1) 累加int main(){ fork()||
2017-01-21 22:59:18 458
原创 Linux 文件 操作
文件指针操作文件的创建 fp=fopen(argv[1],”wb”) if(fp==NULL){ perror(“fopen”); }fclose(fp);sprintf(* buffer,); 读写文件1.3 目录操作#include<sys/stat.h>#include<stdio.h>int ret=0;int main(int argc, char *argv[1]){
2017-01-21 22:46:08 200
原创 Linux 编译与调试
动态链接创建和编译gcc -E test.c -o test.i //预处理define NUM 1+2int a=NUM*NUM =1+2*1+2 NUM*NUM gcc -S test.i -o test.s 、、编译 出来为汇编代码as test.s -o test.o 链接: gcc test.o -o gcc test.c -o test ./testgcc *.c -
2017-01-20 21:13:29 267
原创 牛客网 刷题笔记2017年1月19日
内联函数和宏的区别内联函数在编译的时候可以调试,而宏不可以。内联函数会对参数类型做安全检查或自动转换,而宏不会。内联函数是需要消耗内存的,而宏是字符串替换,所以不占用内存。内联函数可以访问类成员变量,而宏则不可以。在类中声明同时定义成员函数,自动转化为内联函数。快速排序实现是基于分治算法。分解 解决 合并,每次分解为两个数组,需要logn次划分。快速排序的效率取决于递归次数(深浅)
2017-01-19 19:43:25 496
原创 my Linux 命令学习笔记
sudo passwd root 更改root账户密码沙茶的话,O(∩_∩)O~请忽略 玩学习最大的快乐不是去完成什么成就,而是玩着玩着很快乐,能够解决一些好玩的问题,这些问题永远不是学习掌握的,而是通过思考获得,多思考多分析,自己的运行模式,存在哪些问题,不断自我的修正,直到离开这个世界。请活在另外一个世界吧, 不要在被这个世界浮躁而影响。2017年1月17日su root su切换 2.
2017-01-17 22:39:24 356
原创 git学习
教程看这Ubuntu 64git 版本控制安装gitsudo apt-get git install配置用户 : git config --global user.name "YourName"git config --global user.email "email@example.com"创建Git版本库 建立 仓库文件夹$ mkdir learngit$ cd learngit初始化
2017-01-16 20:58:19 231
原创 C++的博客整理
2015-03-30: const加载定义的函数后面—— 常成员函数可以理解为是一个“只读”函数,它既不能更改数据成员的值,也不能调用那些能引起数据成员值变化的成员函数,只能调用const成员函数 1.const int &x和int const &x有何区别? const int x=1; int const x=1; 还有 const int &y=x; int const &y
2017-01-16 20:50:20 299
原创 c 文件
文件读写文件操作FILE * fp;fp = fopen(argv[1],"r") // read textif(fp==NULL){ perror("fopen");}fp = fopen(argv[1],"w") // read textif(fp==NULL){ perror("fopen");}fp = fopen(argv[1],"r") // read bi
2017-01-16 20:42:34 339
原创 2017年1月11日 函数指针复习
函数指针int sum(int a,int b){ return a+b;}int sub(int a,int b){ return a-b;}int cal(int x,int y,int (*p)(int ,int )) // 函数指针{ printf("result is = %d,p(x,y)); }int main(){ cal(a,b,sub
2017-01-16 20:40:00 227
原创 LeetCode 258. Add Digits 题解
Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, r
2017-01-16 20:37:56 220
原创 C 空格替换
如果长度一样,就不要考虑覆盖了 空格替换成%020 就差一步啊,傻啊,先挪动,就不会覆盖了。 画图看变化前后,不就清楚了,想你没#include<stdio.h>#include<stdlib.h>#include<string.h>/*2.将 字 符 串 中 的 空 格 替 换 成 “%020”*/void space_fun(char *, int len);int main(
2017-01-16 20:31:18 278
原创 C 排序算法 (冒泡)(选择)|(插入)|(快速)
排序算法冒泡2 5 8 6 9 1 7 3 4 5for(int i=0;i<9;i++){ for(int j=0;j<9-i;j++) { if(a[j]<a[j+1]) }}选择排序基准(位置)for(int i=N;i>1;i--){ int max_pos=0; for(int j=0;j<i;j++) {
2017-01-13 09:49:05 176
原创 C++学习笔记
2016年12月27日 2.4.3 用户定义函数// ourfun.cpp -- define your own function#include<iostream>void simon(int); // function protype for simon()int main(){ using namespace std; simon(4); // call the
2017-01-13 08:55:00 324
原创 leetcode 350. Intersection of Two Arrays II
https://leetcode.com/problems/intersection-of-two-arrays-ii/妈蛋,我还是个弱鸡,这样的题目也不能解决,~~(>_<)~~,算了自己不正确的思路,就不写了 既然他们是有序的,当然在此之前是给她排序哈.sort(nums1.begin(),nums1.end());sort(nums1.begin(),nums1.end());然后确定长度
2017-01-03 09:02:31 233
原创 leetcode-389. Find the Difference
2017年1月2日 https://leetcode.com/problems/find-the-difference/class Solution {public: char findTheDifference(string s, string t) { for(int i=1;i<s.size();i++) {
2017-01-02 15:23:16 219
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人