Careercup | Chapter 6
6.2 There is an 8x8 chess board in which two diagonally opposite corners have been cut off. You are given 31 dominos, and a single domino can cover exactly two squares. Can you use the 31 dominos to cover the entire board? Prove your answer (byproviding an example or showing why it's impossible).
很巧妙的反证。
6.3 You have a five-quart jug, a three-quart jug, and an unlimited supply of water (but no measuring cups). How would you come up with exactly four quarts of water? Note that the jugs are oddly shaped, such that filling up exactly "half" of the jug would be impossible.
得到1:装满3---从3倒进5---装满3---从3倒进5,此时3的瓶子里装的就是1.
得到2:装满5---从5倒进3,此时5的瓶子里装的就是2;
得到3:装满3;
得到4:装满5--从5倒进3--倒空3--从5倒进3(3里面有2)---装满5---从5再倒进3(倒进了1),现在5的瓶子里装的就是4;
得到5:装满5;
得到6:得到1之后再装满5就行;
得到7,得到2之后再装满5;
得到8, 装满3和5;
6.4 A bunch of people are living on an island, when a visitor comes with a strange order: all blue-eyed people must leave the island as soon as possible. There will be a flight out at 8:00pm every evening. Each person can see everyone else's eye color, but they do not know their own (nor is anyone allowed to tell them). Additionally, they do not know how many people have blue eyes, a/though they do know that at least one person does. How many days will it take the blue-eyed people to leave?
没想到。应该从最基础的case开始。
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, he toggles every third locker (closes it if it is open or opens it if it is closed). This process continues for / 00 passes, such that on each pass i, the man toggles every ith locker. After his 100th pass in the hallway, in which he toggles only locker #100, how many lockers are open?
都是好题。
微软面试题(考思维)
1. 有两个房间,一间房里有三盏灯,另一间房有控制着三盏灯的三个开关, 这两个房间是分割开的,从一间里不能看到另一间的情况。 现在要求受训者分别进这两房间一次,然后判断出这三盏灯分别是由哪个开关控制的。 有什么办法呢?
进入开关房, 打开a灯,约5分钟后关掉,打开b灯;马上进入灯房,亮着的灯为b灯,灯泡有点热的是a灯,另一个就是c灯;
关键是利用到灯泡发热。
2. 你让一些人为你工作了七天,你要用一根金条作为报酬。金条被分成七小块,每天给出一块。 如果你只能将金条切割两次,你怎样分给这些工人?
1+2+4
3. 假设你有一个用1001个整数组成的数组,这些整数是任意排列的,但是你知道所有的整数都在1到1000(包括1000)之间。此外,除一个数字出现两次外,其他所有数字只出现一次。假设你只能对这个数组做一次处理,用一种算法找出重复的那个数字。如果你在运算中使用了辅助的存储方式,那么你能找到不用这种方式的算法吗?
可以用求和+减法,也可以用xor。
Careercup | Chapter 6的更多相关文章
- Careercup | Chapter 1
1.1 Implement an algorithm to determine if a string has all unique characters. What if you cannot us ...
- Careercup | Chapter 3
3.1 Describe how you could use a single array to implement three stacks. Flexible Divisions的方案,当某个栈满 ...
- Careercup | Chapter 2
链表的题里面,快慢指针.双指针用得很多. 2.1 Write code to remove duplicates from an unsorted linked list.FOLLOW UPHow w ...
- Careercup | Chapter 8
8.2 Imagine you have a call center with three levels of employees: respondent, manager, and director ...
- Careercup | Chapter 7
7.4 Write methods to implement the multiply, subtract, and divide operations for integers. Use only ...
- CareerCup Chapter 9 Sorting and Searching
9.1 You are given two sorted arrays, A and B, and A has a large enough buffer at the end to hold B. ...
- CareerCup chapter 1 Arrays and Strings
1.Implement an algorithm to determine if a string has all unique characters What if you can not use ...
- CareerCup Chapter 4 Trees and Graphs
struct TreeNode{ int val; TreeNode* left; TreeNode* right; TreeNode(int val):val(val),left(NULL),rig ...
- Careercup | Chapter 5
5.1 You are given two 32-bit numbers, N andM, and two bit positions, i and j. Write a method to inse ...
随机推荐
- rs485多主
因复位时I/O口都输出高电平.如果把I/O口直接与RS-485接口芯片的驱动器使能端DE端相连,会在CPU复位其间DE为高,从而使本节点处于发送状态.如果此时总线上其它节点在发送数据,则此次数据传输将 ...
- Letters CodeForces - 978C (二分)
Time limit4000 ms Memory limit262144 kB There are nn dormitories in Berland State University, they a ...
- LayaAir环境TypeScript
1.1 Node.js下载 TypeScript开发HTML5需要Node.js环境,如果没有安装过的,请前往官方下载(建议LTS版本),如图1,URL地址为:https://nodejs.org ...
- navicat for mysql 在win7下设置定时计划之导出数据处理
navicat for mysql 在win7下设置定时计划之导出数据处理 博客分类: mysql navitcatmysql定时任务导出 前两篇记录了,navicat for mysql计划的入门 ...
- 关于 NSData 的数据类型(2进制,16进制之间)及深入剖析
1. NSData 与 NSString NSData-> NSString NSString *aString = [[NSString alloc initWithData:adataenc ...
- django自定义过滤器和标签
1.自定义过滤器和标签的流程: 1.在某个app下创建一个名为templatetags(必需,且包名不可变)的包.假设我们在名为app01的app下创建了一个templatetags的包,并在该包下创 ...
- Python包和日志模块
1.什么是包 包是模块的一种形式,包的本质就是一个含有__init__.py文件的文件夹 2.为什么要有包 提高开发人员维护性 3.如何用包 导入包就是在导包下的__init__.py ...
- 后台线程读取指定的web.config
//读取配置文件,订单地址修改接口地址 ExeConfigurationFileMap configMap = new ExeConfigurationFileMap(); configMap.Exe ...
- 利用MVC模式简单设计jsp分页效果
利用Mysql创建一个表Car 用Eclipse创建一个Dynamic Web Project 在lib目录下导入Mysql的jar包 创建如下文件 package com.bean; public ...
- Java中接口的作用
转载于:https://www.zhihu.com/question/20111251 困惑:例如我定义了一个接口,但是我在继承这个接口的类中还要写接口的实现方法,那我不如直接就在这个类中写实现方法岂 ...