做题2015.3.27
来源:互联网 发布:python import thread 编辑:程序博客网 时间:2024/06/10 16:50
题目描述:
在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。
例如下面的二维数组就是符合这种约束条件的。如果在这个数组中查找数字7,则返回true;如果查找数字5,由于数组不含有该数字,则返回false。
12 8
9
2
4
9 12
4 7
10 13
6
8
11 15
系统设计题
微博中的url往往很长,发送前要转化为tinyurl
1、url如何转为tinyurl编码
例子:http://dou.bz/1WEhro
该系统使用6个短码字符来表示任何长度的网址。 有效的字符代码是ASCII 'A'到'Z'和'0'的'5',其中每个字符包含2 ^ 5(32)状态。 6短码字符可用于绘制32 ^ 6(1073741824)的网址
loop1: while true loop1:
calculate md5 of the URL
loop2: from 1st 4 bytes to 4th 4 bytes of md5 result loop2:
cast the 4 bytes to an integer
loop3: for shortCodeChar[0] to shortCodeChar[5]
use 1st 5 bits of the integer to find the value in codeMap
remove 5 bits from the integer
end loop3
save shortCodeChar as shortCode
if shorCode does not exist in database
insert the short code and original URL into database
break loop1:
else
retrieve the stored URL from database
if original URL equals to URL stored in database
break loop1:
end if
end if
end loop2
insert '-'
end loop1
return shortCode
Note: codeMap contains value of valid characters from 'a' to 'z' (index 0 to 25) and '0'-'5' (index 26 to 31).
2、如果用户输入一个已经转换过的URL,如何快速定位到已经生成了的tinyurl
3、如果数据为10亿条,需要10个tinyurl服务器,怎么设计?
- 做题2015.3.27
- 做题
- 做题
- 做题
- 做题
- 做题
- 做题与做项目
- 陪她做题
- 开始做题。。。
- 做题沙龙
- 做题小结
- POJ做题分类
- USACO做题介绍
- 数据结构题 怎么做
- 做测试题
- 天天做题
- 做题感言
- 做题感受
- iOS开发工具集2
- HashMap_经典存储_分拣思路
- 【C语言】字符串复制。(不能使用strcpy函数)
- hive表信息查询:查看表结构、表操作等
- 使用springMVC的详细步骤
- 做题2015.3.27
- SharePoint Event Receiver 网站范围和绑定的列表范围
- Qt学习-QString用法总结( setNum, number 函数)
- 大家好,来露个脸。
- 各种日期转换
- 使用mod_rewrite优化seo
- 题目1070 今年的第几天? 九度Online Judge
- One Cause of java.net.SocketTimeoutException: Read timed out
- 黑马程序员-----关于懒汉式和饿汉式小结