- 博客(12)
- 资源 (1)
- 收藏
- 关注
原创 lintcode ----两个链表的交叉
想法:遍历两个链表到最后,判断连个链表最后的位置是否相同,不同直接返回;用两个变量记录链表的长度,哪个长 先往后遍历到一样长,接着另一个也开始同时遍历,直到相等,返回头指针 ListNode *getIntersectionNode(ListNode *headA, ListNode *headB) { // write your code
2016-06-30 22:48:34 1305
原创 lintcode ----最长连续序列
int longestConsecutive(vector &num) { // write you code here set res; int len=1; int tem=1; for(int i=0;i<num.size();i++) { res.insert(
2016-06-21 16:00:13 261
原创 lintcode --交错正负数
思路: 首先判断正负数的个数 哪个多,用少的那个去“插入”多的那个 void rerange(vector &A) { // write your code here sort(A.begin(),A.end()); int mi=0,ma=0; for(int i=0;i<A.size();i++) {
2016-06-21 14:18:46 529
原创 lintcode ----搜索二维矩阵
法一: 右上角开始判断,小于target下移,大于target左移(37ms)int searchMatrix(vector > &matrix, int target) { // write your code here if(matrix.empty()) return 0; int rows= matrix.s
2016-06-16 15:19:41 1125
原创 lintcode ---- 最长公共前缀
思路:只要不相等就返回,否则res一直累加! string longestCommonPrefix(vector &strs) { // write your code here string res=""; int t = INT_MAX; if(strs.empty()) ret
2016-06-16 13:38:58 568
原创 fcntl 函数小揭秘
功能描述:根据文件描述词来操作文件的特性。 #include #include int fcntl(int fd, int cmd); int fcntl(int fd, int cmd, long arg); int fcntl(int fd, int cmd, struct flock *lock); [描述] fcntl()针对(文件)描述符提供控制。参数fd
2016-06-13 17:32:54 246
转载 termios的结构 ----Linux
termios 结构是在POSIX规范中定义的标准接口,它类似于系统V中的termio接口,通过设置termios类型的数据结构中的值和使用一小 组函数调用,你就可以对终端接口进行控制。 可以被调整来影响终端的值按照不同的模式被分为如下几组: 1.输入模式 2.输出模式 3.控制模式 4.本地模式 5.特殊控制模式 最小的termios结构的典型定义
2016-06-13 17:30:38 388
转载 串口参数
串口简介 串行口是计算机一种常用的接口,具有连接线少,通讯简单,得到广泛的使用。常用的串口是 RS-232-C 接口(又称 EIA RS-232-C)它是在 1970 年由美国电子工业协会(EIA)联合贝尔系统、 调制解调器厂家及计算机终端生产厂家共同制定的用于串行通讯的标准。它的全名是"数据终端设备(DTE)和数据通讯设备(DCE)之间串行二进制数据交换接口技术标准"该标准规定采用一个 2
2016-06-13 17:28:18 465
原创 lintcode ----打劫房屋
法一:每次把当前位前一位的值和当前位加 res[i-2]的值比较,取最大赋值给当前位,遍历完成最后一位即为最大long long houseRobber(vector A) { // write your code here vector res(A.size(),0); res[0]=A[0]; res[1]=max(A[0],A[
2016-06-13 16:58:25 363
原创 lintcode ----单词搜索
bool tf[100][100]; bool temp(int i,int j,vector> &board,int res,string word) { if(res==word.length()) return true; if(j>=0&&i>=0&&j<board[i].size()&&i<board
2016-06-12 18:05:48 205
原创 lintcode ----统计数字
int digitCounts(int k, int n) { // write your code here int res=0; if(k==0) res=1; for(int i=0;i<=n;i++) { int tem=i; while(
2016-06-07 22:35:50 1368
原创 lintcode ----寻找缺失的数
方法一:181 ms 排序后 与i 不等即为答案 int findMissing(vector &nums) { // write your code here int res=0; int i; sort(nums.begin(),nums.end()); for(i=0;i<
2016-06-07 15:07:07 298
Computational Fourier Optics:a MATLAB tutorial
2017-12-25
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人