09 2015 档案
摘要:Given a sorted integer array without duplicates, return the summary of its ranges. For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"]. 将没有重复,已经排好序的数组,返回下面的形式,如果连续就输出头尾的字符串,如果一个就返回一个字符 /** *...
阅读全文
摘要:一、顺序容器概述:一个容器就是一些特定类型对象的集合1、顺序容器类型:vector、deque、list、forward_list、array、stringstring和vector将元素保存在连续的内存空间,所以用下标访问很快,但是在中间位置添加或删除元素很耗时list和forward_list在...
阅读全文
摘要:Given a singly linked list, determine if it is a palindrome. Follow up:Could you do it in O(n) time and O(1) space? 1、朴素方法 /** * Definition for singly-linked list. * struct ListNode { * int val...
阅读全文
摘要:Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists:A: a1 → a2 ↘ ...
阅读全文
摘要:Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. 把两个排列好的链表,融合成新的排列好的链表 1、自己的朴素方式 /** * Definition for sing...
阅读全文
摘要:Given a sorted linked list, delete all duplicates such that each element appear only once. For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3. /** * Definition for singly-link...
阅读全文
摘要:一、IO类1、iostream定义了读写流的基本类型,fstream定义了读写命名文件的类型,sstream定义了读写内存string对象的类型2、不能拷贝IO对象,因此不能将形参或返回类型设置为流类型:通常以引用方式传递和方回流3、读写一个IO对象会改变其状态,因此传递和返回的引用不能是const...
阅读全文
摘要:一、定义抽象数据类型1、成员函数的声明必须在类的内部,定义可以内部也可以外部;作为接口组成部分的非成员函数,定义和声明都在外部如果类函数定义在类内部,则隐式为inline函数在声明时声明inline,然后在类外定义函数,可以可以构造inline函数inline成员函数应该和类的定义在同一个头文件中2...
阅读全文
摘要:Remove all elements from a linked list of integers that have value val.ExampleGiven: 1 --> 2 --> 6 --> 3 --> 4 --> 5 --> 6, val = 6Return: 1 --> 2 -->...
阅读全文
摘要:Reverse a singly linked list./** * Definition for singly-linked list. * struct ListNode { * int val; * struct ListNode *next; * }; */struct Li...
阅读全文
摘要:Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this in place with co...
阅读全文
摘要:#define ElementType intstruct Node;typedef struct Node *PtrToNode; //不懂书上分这么多步干嘛,后面自己写方便点typedef PtrToNode List;typedef PtrToNode Position;Lis...
阅读全文
摘要:一、参数传递1、形参为引用类型时,将绑定到相应的实参上,否则为实参的拷贝;在C++中建议用引用类型代替指针2、const 形参:对于顶层的const,在函数形参中无效,也不能构成重载函数形参中尽量使用常量引用,对于普通引用会有误导,主要是非常量引用会导致函数不能接受常量的类型3、数组形参:传递给函数...
阅读全文
摘要:一、题目Given an array and a value, remove all instances of that value in place and return the new length.The order of elements can be changed. It doesn't...
阅读全文
摘要:1、if_else语句:else会与离它最近的尚未匹配的if匹配,所以当只使用一半的if时,最好用{}包起来2、switch语句:不要省略break;还有最后default;3、for语句:for语句头中定义的对象,只有在for循环体中可见for(int i = 0; i < n; i++) ...
阅读全文
摘要:1、求值顺序:运算对象的求值顺序与优先级和结合律无关i = f(i) + g(i)*h(i) + j(i); //如果这里的各个函数与i无关,则无所谓,如果内部都改变了i则会出错如果几个函数影响同一个对象,则会产生未定义的行为2、当拿不准求值顺序时,用括号来强制组合3、赋值运算符:左侧...
阅读全文
摘要:1、matlab设置默认路径 在原来的默认路径(bin)下创建一个名为startup.m的文件,内容为相对路径 cd ..\..\WorkSpace\ 或绝对路径 cd F:\Program\MATLAB\WorkSpace\ 即可。再次打开MATLAB时便会自动执行startup.m文件,将工作路径转至WorkSpace下。 2、画图 例程: figure...
阅读全文
摘要:Given a non-negative number represented as an array of digits, plus one to the number.The digits are stored such that the most significant digit is at...
阅读全文
摘要:一、string1、包含头文件string; 命名空间std#includeusing std::string2、读取操作时,string对象会自动忽略开头的空白,直到遇到下一个空白如果想要保留空白,使用getline函数:读到换行符为止,但不把换行符写入到string中string s1, s2,...
阅读全文
摘要:再次重温下C++ Primer第一章、开始1、GNU编译器使用g++$ g++ -o prog1 prog1.cc2、while(std::cin >> value)使用一个istream作为条件时,如果遇到Eof,或无效输入(不匹配类型)则判断为假,跳出第二章:变量和基本类型一、基本内置类型1、如...
阅读全文
摘要:一、常用命令:普通的如cd、ls和linux下一样 clc:清除工作窗口中的所有显示内容 clf:清除图形窗口 whos:列出当前工作空间中所有变量,以及它们的名字、尺寸(比如一个矩阵或数组的行列维数)、所占字节数、属性等信息。这些信息都显示在matlab中的workspace窗口中 shift+Enter:换行输入,可以输入多条命令,然后同时执行它 二、数据类型 默认存储类型为dou...
阅读全文

浙公网安备 33010602011771号