2014-05-08 21:33
原题:
largest number that an int variable can fit given a memory of certain size
题目:给定特定内存大小,请问int型的变量能表示的最大整数是多少?
解法:这个“Guy”出的题目总是这样表意不清。特定大小的内存是什么意思?他要说的是字长吧?16位int占两字节,32位以后int都占四字节。这样能表示的最大整数就是(1 << sizeof(int) * 8 - 1) - 1。
代码:
// http://www.careercup.com/question?id=4847954317803520
// For n bits, signed integer can reach 2 ^ (n - 1) - 1.
// For n bits, unsigned integer can reach 2 ^ n - 1.
// My question is: is this a real Google interview question? Onsite interview?
// This guy named 'guy' has been posting an awful lot of questions on Careercup, which contains some difficult, tricky, trivial and stupid ones.
// I doubt if he's simply trying to gather more reputation, by means of spam questions. If he's not telling the truth, he's polluting Careercup and misleading other visitors here.
// He should be warned and punished.
int main()
{
return ;
}
Careercup - Google面试题 - 4847954317803520的更多相关文章
-
Careercup - Google面试题 - 5732809947742208
2014-05-03 22:10 题目链接 原题: Given a dictionary, and a list of letters ( or consider as a string), find ...
-
Careercup - Google面试题 - 5085331422445568
2014-05-08 23:45 题目链接 原题: How would you use Dijkstra's algorithm to solve travel salesman problem, w ...
-
Careercup - Google面试题 - 6332750214725632
2014-05-06 10:18 题目链接 原题: Given a ,) (,) (,), (,) should be returned. Some suggest to use Interval T ...
-
Careercup - Google面试题 - 5634470967246848
2014-05-06 07:11 题目链接 原题: Find a shortest path ,) to (N,N), assume is destination, use memorization ...
-
Careercup - Google面试题 - 5680330589601792
2014-05-08 23:18 题目链接 原题: If you have data coming in rapid succession what is the best way of dealin ...
-
Careercup - Google面试题 - 5424071030341632
2014-05-08 22:55 题目链接 原题: Given a list of strings. Produce a list of the longest common suffixes. If ...
-
Careercup - Google面试题 - 5377673471721472
2014-05-08 22:42 题目链接 原题: How would you split a search query across multiple machines? 题目:如何把一个搜索que ...
-
Careercup - Google面试题 - 6331648220069888
2014-05-08 22:27 题目链接 原题: What's the tracking algorithm of nearest location to some friends that are ...
-
Careercup - Google面试题 - 5692127791022080
2014-05-08 22:09 题目链接 原题: Implement a class to create timer object in OOP 题目:用OOP思想设计一个计时器类. 解法:我根据自 ...
随机推荐
-
powershell小工具
保存为.ps1文件Set-ExecutionPolicy UnrestrictedSet-ExecutionPolicy Restricted 1. 批量修改文件后缀 $CodeFileDir=&qu ...
-
LeetCode FindMinimuminRotatedSorteArray &;&;FindMinimuminRotatedSorteArray2
LeetCode上这两道题主要是使用二分搜索解决,是二分搜索算法的一个应用,根据条件每次舍弃一半,保留一半. 首先第一题: FindMinimuminRotatedSorteArray(时间复杂度为二 ...
-
[POJ] 3368 / [UVA] 11235 - Frequent values [ST算法]
2007/2008 ACM International Collegiate Programming Contest University of Ulm Local Contest Problem F ...
-
很好用的一个类:TJvAppXMLFileStorage
以前写软件的时候,在处理软件配置信息的时候,总是要写很多重复的代码,把配置信息写到Ini文件当中.昨天到网上查了一下,发现JVCL中提供了一个非常好用的类TJvAppXMLFileStorage,可以 ...
-
LVS 负载均衡解决方案 (windows IIS)
LVS 负载均衡解决方案 因为我们的产品运行的主流平台是WINDOWS+IIS+SQLSERVER(2000以上版本),而LVS+KEEPALIVED是LINUX下的四层负载均衡软件.其有如下特点: ...
-
shell 批量修改较长字符串 字符串内容之间更换位置
cat 1.txt src='http://img2.tgbusdata.cn/v2/thumb/jpg/MkY5Myw2NTUsMzAzLDksMywxLC0xLDAscms1MCwxOTIuMTY ...
-
python---循环双向链表实现
这个方案里的尾插入,就使用了更高效的prev指标. 但感觉remove的代码不够和前面统一, 我有代码洁癖了???? # coding = utf-8 # 双向链表 class Node: # 双向链 ...
-
pip install 安装出现问题:UnicodeEncodeError: &#39;ascii&#39; codec can&#39;t encode characters in position XX的解决办法
pip install 安装出现问题:UnicodeEncodeError: 'ascii' codec can't encode characters in position XX的解决办法 转自c ...
-
[daily] SNAT和DNAT
SNAT,DNAT,MASQUERADE都是NAT MASQUERADE是SNAT的一个特例 SNAT是指在数据包从网卡发送出去的时候,把数据包中的源地址部分替换为指定的IP,这样,接收方就认为数据包 ...
-
js原型、原型链、作用链、闭包全解
https://www.2cto.com/kf/201711/698876.html [对象.变量] 一个对象就是一个类,可以理解为一个物体的标准化定义.它不是一个具体的实物,只是一个标准.而通过对象 ...