02 2016 档案

摘要:Given a pattern and a string str, find if str follows the same pattern. Here follow means a full match, such that there is a bijection between a lette 阅读全文
posted @ 2016-02-27 18:57 周洋 阅读(308) 评论(0) 推荐(0)
摘要:Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'. A region is captured by flipping all 'O's into 'X's in that surrounded 阅读全文
posted @ 2016-02-27 00:23 周洋 阅读(492) 评论(0) 推荐(0)
摘要: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 ma 阅读全文
posted @ 2016-02-26 23:02 周洋 阅读(150) 评论(0) 推荐(0)
摘要:Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level). For example:Given binary tree {3 阅读全文
posted @ 2016-02-26 17:59 周洋 阅读(270) 评论(0) 推荐(0)
摘要:Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest l 阅读全文
posted @ 2016-02-26 16:58 周洋 阅读(179) 评论(0) 推荐(0)
摘要:Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest l 阅读全文
posted @ 2016-02-26 09:51 周洋 阅读(143) 评论(0) 推荐(0)
摘要:Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as a binary tree in which the dept 阅读全文
posted @ 2016-02-26 09:42 周洋 阅读(186) 评论(0) 推荐(0)
摘要:Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight). For example, the 32-bit 阅读全文
posted @ 2016-02-25 19:14 周洋 阅读(143) 评论(0) 推荐(0)
摘要:Given an integer, write a function to determine if it is a power of three. Follow up:Could you do it without using any loop / recursion? //cmath里内置的有关 阅读全文
posted @ 2016-02-25 17:25 周洋 阅读(185) 评论(0) 推荐(0)
摘要:Given an integer, write a function to determine if it is a power of two. 题解:一次一次除2来做的话,效率低。所以使用位运算的方法(左移一位相当于原数乘2)列出在int范围内的所有2的倍数,然后和n异或如果等于0,那么n就是它( 阅读全文
posted @ 2016-02-25 15:47 周洋 阅读(285) 评论(0) 推荐(0)
摘要:Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array. For example,Given nums = [0, 1, 阅读全文
posted @ 2016-02-25 12:41 周洋 阅读(231) 评论(0) 推荐(0)
摘要:A peak element is an element that is greater than its neighbors. Given an input array where num[i] ≠ num[i+1], find a peak element and return its inde 阅读全文
posted @ 2016-02-25 12:18 周洋 阅读(185) 评论(0) 推荐(0)
摘要:Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in or 阅读全文
posted @ 2016-02-25 10:58 周洋 阅读(173) 评论(0) 推荐(0)
摘要:Search for a Range Given a sorted array of integers, find the starting and ending position of a given target value. Your algorithm's runtime complexit 阅读全文
posted @ 2016-02-25 10:53 周洋 阅读(264) 评论(0) 推荐(0)
摘要:1.函数本身可以赋值给变量(即变量可以指向函数)。而其实函数名本身就是指向函数的变量。 2.一个函数可以接受另一个函数作为参数。这种函数称为高阶函数。 def add(a,b,f) return f(a)+f(b) 3.map和reduce map函数接收两个参数,一个是函数,一个是Iterable 阅读全文
posted @ 2016-02-24 17:16 周洋 阅读(416) 评论(0) 推荐(0)
摘要:“apt-get”命令,这是用于管理已安装程序的通用命令。 安装:apt-get install name 卸载:apt-get remove name 卸载并清除配置:apt-get --purge remove name 更新信息库:apt-get update 系统升级:apt-get upg 阅读全文
posted @ 2016-02-22 22:47 周洋 阅读(2519) 评论(0) 推荐(0)
摘要:1.vector::pop_back() 删除vector的最后一个元素,vector的大小减一,删了的元素被销毁。 2.vector::erase() iterator erase (iterator position); iterator erase (iterator first, itera 阅读全文
posted @ 2016-02-03 21:44 周洋 阅读(6947) 评论(0) 推荐(0)
摘要:原文链接http://www.ibm.com/developerworks/cn/aix/library/1212_lufang_c11new/ 本文将介绍 C++11 标准的两个新特性:defaulted 和 deleted 函数。对于 defaulted 函数,编译器会为其自动生成默认的函数定义 阅读全文
posted @ 2016-02-03 11:51 周洋 阅读(275) 评论(0) 推荐(0)
摘要:每一个class,编译器都会自动生成四个特殊成员函数: destructor(析构函数) default constructor(默认构造函数) copy constructor(copy构造函数) copy assignment operator =(copy assignment操作符) 但是有 阅读全文
posted @ 2016-02-03 11:44 周洋 阅读(684) 评论(0) 推荐(0)
摘要:1.const成员函数不能更改成员变量 #include <bits/stdc++.h> using namespace std; class CtextBlock { public: size_t length() const; private: char* pText; size_t textL 阅读全文
posted @ 2016-02-03 10:42 周洋 阅读(368) 评论(0) 推荐(0)
摘要:1.若用户刷新一个包含POST表单的页面,那么请求将会重新发送造成重复。 这通常会造成非期望的结果,比如说重复的数据库记录。如果用户在POST表单之后被重定向至另外的页面,就不会造成重复的请求了。我们应每次都给成功的POST请求做重定向。 2. (1)form.is_valid()查看form中的数 阅读全文
posted @ 2016-02-01 22:54 周洋 阅读(296) 评论(0) 推荐(0)