摘要:
9.2 Imagine a robot sitting on the upper left corner of an X by Y grid. The robot can only move in two directions: right and down. How many possible p...
阅读全文
posted @ 2015-09-17 23:22
Grandyang
阅读(989)
推荐(0)
摘要:
9.1 A child is running up a staircase with n steps, and can hop either 1 step, 2 steps, or 3 steps at a time. Implement a method to count how many pos...
阅读全文
posted @ 2015-09-17 03:08
Grandyang
阅读(1070)
推荐(0)
posted @ 2015-09-17 00:36
Grandyang
阅读(16)
推荐(0)
摘要:
Given a string that contains only digits 0-9 and a target value, return all possibilities to add binaryoperators (not unary) +, -, or * between the di
阅读全文
posted @ 2015-09-16 21:01
Grandyang
阅读(20166)
推荐(2)
摘要:
在C++和Java的泛式编程中,模板template的使用是必不可少的,但是Java中没有template关键字,所以两者的写法还是有些许区别的,请参见如下代码:Java的模板// Javapublic class Cell { private K _key; private V _va...
阅读全文
posted @ 2015-09-16 12:13
Grandyang
阅读(950)
推荐(0)
摘要:
8.10 Design and implement a hash table which uses chaining (linked lists) to handle collisions.这道题让我们实现一个简单的哈希表,我们采用了最简单的那种取余映射的方式来实现,我们使用Cell来保存一对对的k...
阅读全文
posted @ 2015-09-16 03:12
Grandyang
阅读(1174)
推荐(0)
摘要:
在Java中,如果A是基类,B是A的派生类,那么instanceof可以用来判断一个实例对象是A还是B,相当于一个二元操作符,但与==, >, (a)) { // Process B } if (C *c = dynamic_cast (a)) { // P...
阅读全文
posted @ 2015-09-15 11:37
Grandyang
阅读(1184)
推荐(0)
摘要:
快捷键 功能解释 工具操作 enter 完成当前操作 ~ 终止当前操作 insert 插入工具编辑模式 w 移动工具 e 旋转工具 r 缩放工具 y 非固定排布工具 shift+Q 选择工具,(切换到)成分图标菜单 alt+Q 选择工具,(切换到)多边形选择图标菜单 Q 选择工具,(切换到)成分图标...
阅读全文
posted @ 2015-09-15 00:23
Grandyang
阅读(1613)
推荐(0)
摘要:
8.9 Explain the data structures and algorithms that you would use to design an in-memory file system. Illustrate with an example in code where possibl...
阅读全文
posted @ 2015-09-14 12:09
Grandyang
阅读(1111)
推荐(0)
摘要:
8.8 Othello is played as follows: Each Othello piece is white on one side and black on the other. When a piece is surrounded by its opponents on both ...
阅读全文
posted @ 2015-09-13 13:18
Grandyang
阅读(1300)
推荐(0)
摘要:
8.7 Explain how you would design a chat server. In particular, provide details about the various backend components, classes, and methods. What would ...
阅读全文
posted @ 2015-09-12 05:31
Grandyang
阅读(945)
推荐(0)
摘要:
Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. Example 1: Input: n = 12 O
阅读全文
posted @ 2015-09-11 12:06
Grandyang
阅读(42076)
推荐(2)
摘要:
之前在机子装了个很早版本的MinGW,苦于不支持c++11,所以打算卸载掉安装个新版本的。可是网上找了很多版本装好后,编译成功,运行的时候总是弹出 *.exe has stopped working的错误,试了好几个都不行,很苦恼,最后终于找到了一个64位的MinGW,我装的是4.8.1版本的,亲测...
阅读全文
posted @ 2015-09-10 12:49
Grandyang
阅读(516)
推荐(0)
摘要:
8.6 Implement a jigsaw puzzle. Design the data structures and explain an algorithm to solve the puzzle. You can assume that you have a f itsWith metho...
阅读全文
posted @ 2015-09-09 12:02
Grandyang
阅读(2292)
推荐(0)
摘要:
8.5 Design the data structures for an online book reader system.这道题OOB的题让我们设计一个在线读书系统,还是没有任何提示,所以发挥空间很大。根据书上的解答,我们设计一个具有基本功能的系统:1. 用户会员的建立和延长2. 搜索书库中的...
阅读全文
posted @ 2015-09-08 10:24
Grandyang
阅读(966)
推荐(0)
摘要:
vtkMatrix4x4是VTK中的一个表示4x4矩阵的一种数据结构,有时候我们想把其保存到一个文件中,那么可以使用如下的代码:void writeVtkMatrix4x4ToFile(const vtkMatrix4x4 *m, char *filename) { ofstream fout...
阅读全文
posted @ 2015-09-08 07:31
Grandyang
阅读(954)
推荐(0)
摘要:
Givennpoints on a 2D plane, find the maximum number of points that lie on the same straight line.ExampleGiven 4 points:(1,2),(3,6),(0,0),(1,3).The max...
阅读全文
posted @ 2015-09-08 02:39
Grandyang
阅读(1233)
推荐(0)
摘要:
You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality c
阅读全文
posted @ 2015-09-08 02:30
Grandyang
阅读(10736)
推荐(0)
摘要:
8.4 Design a parking lot using object-oriented principles. LintCode上的原题,请参见我的另一篇博客Parking Lot 停车场问题。 这道题让我们实现一个停车位的数据结构,由于题目没给任何多余的信息,所以自由度很大,比如能停放什么种
阅读全文
posted @ 2015-09-07 11:28
Grandyang
阅读(5599)
推荐(0)
摘要:
在C++的OOB编程中,有时候我们会遇到这样的错误Error: 'has incomplete type',forward declaration of 'class x',那么是什么原因引起的这个问题呢,我们首先来看下面这段代码:// Error: field '_a' has incomplet...
阅读全文
posted @ 2015-09-07 11:09
Grandyang
阅读(1612)
推荐(0)
摘要:
8.3 Design a musical jukebox using object-oriented principles.CareerCup这书实在是太不负责任了,就写了个半调子的程序,说是完整版也可以下载到,但是我怎么找不到,谁知道在哪里下载请告诉博主,多谢啦~class Song;class ...
阅读全文
posted @ 2015-09-07 07:06
Grandyang
阅读(982)
推荐(0)
摘要:
C++11系列-什么是C++11【Java】Final 与 C++ Const的区别C++开发者都应该使用的10个C++11特性史上最明白的 NULL、0、nullptr 区别分析C语言堆栈入门——堆和栈的区别栈空间和堆空间C++内存分配方式详解——堆、栈、自由存储区、全局/静态存储区和常量存储区A...
阅读全文
posted @ 2015-09-06 13:42
Grandyang
阅读(531)
推荐(0)
摘要:
8.2 Imagine you have a call center with three levels of employees: respondent, manager, and director. An incoming telephone call must be first allocat...
阅读全文
posted @ 2015-09-06 13:15
Grandyang
阅读(838)
推荐(0)
摘要:
Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper and citations is sorted i
阅读全文
posted @ 2015-09-05 05:45
Grandyang
阅读(12514)
推荐(0)
posted @ 2015-09-05 03:37
Grandyang
阅读(229)
推荐(0)
摘要:
由于C++和Java都是面向对象的编程语言,它们的多态性就分别靠虚函数和抽象函数来实现。C++的虚函数可以在子类中重写,调用是根据实际的对象来判别的,而不是通过指针类型(普通函数的调用是根据当前指针类型来判断的)。纯虚函数是一种在父函数中只定义而不实现的一种函数,不能用来声明对象,也可以被称为抽象类...
阅读全文
posted @ 2015-09-04 23:29
Grandyang
阅读(2791)
推荐(0)
摘要:
Given an array containsNnumbers of 0 ..N, find which number doesn't exist in the array.ExampleGivenN=3and the array[0, 1, 3], return2.ChallengeDo it i...
阅读全文
posted @ 2015-09-04 12:01
Grandyang
阅读(1812)
推荐(0)
摘要:
在C++和java中都有枚举enum这个关键字,但是它们之间又不太一样。对于C++来说,枚举是一系列命名了的整型常量,而且从枚举值转化为对应的整型值是在内部进行的。而对于Java来说,枚举更像一个类的命名的实例,你可以自定义枚举的成员,枚举值转化为对应的整型值是再外部进行的。下面以我之前的一篇博客8...
阅读全文
posted @ 2015-09-04 09:41
Grandyang
阅读(1225)
推荐(0)
摘要:
8.1 Design the data structures for a generic deck of cards. Explain how you would subclass the data structures to implement blackjack.这道题让我们设计一个21点纸牌游...
阅读全文
posted @ 2015-09-04 09:07
Grandyang
阅读(2481)
推荐(0)
摘要:
Given an array of citations (each citation is a non-negative integer) of a researcher, write a function to compute the researcher's h-index. According
阅读全文
posted @ 2015-09-04 07:54
Grandyang
阅读(18200)
推荐(0)
摘要:
7.7 Design an algorithm to find the kth number such that the only prime factors are 3,5, and 7.这道题跟之前LeetCode的那道Ugly Number II 丑陋数之二基本没有啥区别,具体讲解可参见那篇,...
阅读全文
posted @ 2015-09-03 22:18
Grandyang
阅读(768)
推荐(0)
摘要:
7.6 Given a two-dimensional graph with points on it, find a line which passes the most number of points.这道题给了我们许多点,让我们求经过最多点的一条直线。给之前那道7.5 A Line Cut ...
阅读全文
posted @ 2015-09-02 23:54
Grandyang
阅读(974)
推荐(0)
摘要:
C++和Java中都有的一个静态关键字Static,可以放在类中的变量或者函数之前,就成了静态变量或者静态函数。静态变量又分为静态全局变量和静态局部变量,可参见网上大神总结的C++全局变量,局部变量,静态全局变量,静态局部变量的区别。在类中的静态变量在定义时需要用类名引导,对其访问时,使用类名或者对...
阅读全文
posted @ 2015-09-02 11:18
Grandyang
阅读(1161)
推荐(0)
摘要:
7.5 Given two squares on a two-dimensional plane, find a line that would cut these two squares in half. Assume that the top and the bottom sides of th...
阅读全文
posted @ 2015-09-01 07:05
Grandyang
阅读(915)
推荐(0)
摘要:
Convert a non-negative integer num to its English words representation. Example 1: Input: num = 123 Output: "One Hundred Twenty Three" Example 2: Inpu
阅读全文
posted @ 2015-08-31 12:18
Grandyang
阅读(16614)
推荐(1)
摘要:
7.4 Write methods to implement the multiply, subtract, and divide operations for integers. Use only the add operator.这道题让我们实现乘法加法和除法,而且规定了只能使用加法。那么我们先...
阅读全文
posted @ 2015-08-30 06:06
Grandyang
阅读(1055)
推荐(0)
摘要:
7.3 Given two lines on a Cartesian plane, determine whether the two lines would intersect.这道题说是在笛卡尔坐标系中,让我们确定两条直线是否相交。那么我们首先要写个直线的类来表示直线,最常见的表示方法为y=kx...
阅读全文
posted @ 2015-08-29 06:43
Grandyang
阅读(1150)
推荐(0)
摘要:
7.2 There are three ants on different vertices of a triangle. What is the probability of collision (between any two or all of them) if they start walk...
阅读全文
posted @ 2015-08-28 10:55
Grandyang
阅读(956)
推荐(0)
摘要:
7.1 You have a basketball hoop and someone says that you can play one of two games.Game 1: You get one shot to make the hoop.Game 2: You get three sho...
阅读全文
posted @ 2015-08-28 10:26
Grandyang
阅读(819)
推荐(0)
摘要:
6.6 There are 100 closed lockers in a hallway. A man begins by opening all 100 lockers. Next, he closes every second locker. Then, on his third pass, ...
阅读全文
posted @ 2015-08-27 11:53
Grandyang
阅读(1331)
推荐(0)