- 博客(21)
- 收藏
- 关注
原创 第十二章 动态内存
12.1动态内存和只能指针 shared_ptr采用引用计数的方式,p = q;// q的引用计数自增1,p的引用计数自减1,当引用计数为0的时候表明没有对象使用它,而被释放内存 通过make_shared来分配动态内存 对动态对象进行值初始化,只需在类型名之后加上()即可 定位new,int *p1 = new (nothrow)
2015-09-09 11:11:55 396
原创 Factorial Trailing Zeroes
Given an integer n, return the number of trailing zeroes in n!.Note: Your solution should be in logarithmic time complexity.思路:如果要知道多少个0,就需要找到他们的约数中,有多少个2和5,由于2的个数必多于5,所以,找到5的个数即可思
2015-05-15 12:48:44 240
原创 Convert Sorted List to Binary Search Tree
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.思路1:最笨的方法,每次插入然后调整思路2:由于是升序有序的,所以子树的根节点必然是中间的那个数,所以可以通过找到子链表的中间节点,两边递归实现找到链表中间节
2015-04-30 19:12:53 295
原创 Word Ladder
Given two words (beginWord and endWord), and a dictionary, find the length of shortest transformation sequence from beginWord to endWord, such that:Only one letter can be changed at a timeEach i
2015-04-30 19:11:50 274
原创 3Sum
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.Note:Elements in a triplet (a,b,c
2015-04-30 19:09:20 417
原创 1004 Trie树
输入输入的第一行为一个正整数n,表示词典的大小,其后n行,每一行一个单词(不保证是英文单词,也有可能是火星文单词哦),单词由不超过10个的小写英文字母组成,可能存在相同的单词,此时应将其视作不同的单词。接下来的一行为一个正整数m,表示小Hi询问的次数,其后m行,每一行一个字符串,该字符串由不超过10个的小写英文字母组成,表示小Hi的一个询问。在20%的数据中n, m在60%
2015-04-08 15:08:19 343
原创 Max Points on a Line
https://leetcode.com/problems/max-points-on-a-line/Given n points on a 2D plane, find the maximum number of points that lie on the same straight line.思路1:一开始想着构造ax+by+c=0的方程,额,好像也可以。。。O(
2015-04-06 16:35:17 329
原创 第七章 类
7.1定义抽象数据类型 读写操作,会改变输入输出流的内容,所以传入时不用常引用(流对象不可被复制,所以采用引用的方式) 能在类内直接初始化的只有const static 常整型(char、int、long),const初始化 class A{ public: const int a ;
2015-03-23 14:50:22 286
原创 CM5.2部署impala中可能遇到的问题及解决方法
1.下载cm的安装文件2.安装集群,自动完成agent启动以后3.部署hive 3.0到Ubuntu mysql 不能远程连接的问题 http://xzuse.iteye.com/blog/989231 3.1 is not allowed to connect to this MySQL serverConnection closed by forei
2015-03-14 03:46:11 2773
转载 卸载 Cloudera Manager 5.1.x.和 相关软件【官网翻译:高可用】
http://www.aboutyun.com/thread-8992-1-1.html重新安装不完整如果你来到这里,因为你的安装没有完成(例如,如果它是由一个虚拟机超时中断),和你想继续安装,然后重新安装,做到以下几点:删除文件和目录:个人建议:这一步虽然是官网这么做,但是下面命令还是不要执行,因为我们后面还会用到下面命令/usr/
2015-03-14 03:44:01 580
原创 集群常见问题及解决方法
状况1: 此时很可能是集群该台host机器的cloudera-scm-agent进程挂掉了,改进程用于与Cloudera Manager进行通信 解决方案:在该台机器上,输入命令/etc/init.d/cloudera-scm-agent status查看该进程的状态 如果提示“Checking for service cloudera-
2015-03-14 03:43:53 1344
原创 Generate Parentheses
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:"((()))", "(()())", "(())()", "()(())", "()()
2015-03-14 03:38:29 270
原创 Binary Tree Maximum Path Sum
Given a binary tree, find the maximum path sum.The path may start and end at any node in the tree.For example:Given the below binary tree, 1 / \ 2 3tips:注意为负数的情况!!!
2015-03-14 03:37:57 282
原创 Candy
There are N children standing in a line. Each child is assigned a rating value.You are giving candies to these children subjected to the following requirements:Each child must have at least on
2015-03-14 03:37:53 283
原创 Trapping Rain Water
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining.For example, Given [0,1,0,2,1,0,1,3,2,1,2,1]
2015-03-14 03:37:09 339
原创 Unique Binary Search Trees II
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n.For example,Given n = 3, your program should return all 5 unique BST's shown below. 1 3
2015-03-14 03:35:50 458
原创 第六章 函数
如果函数调用的参数中,其拷贝类型较大时,比较低效,甚至有类型不支持拷贝操作,因此可以使用引用,避免拷贝 void fcn(const int i ); void fcn(int i ); //会提示重复定义,因为上个的顶层const被忽略了,两者其实没什么不同 非常量引用的初始值必须为左值!!! 所以 const int &r
2015-03-10 13:43:10 368
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人