每天坚持Crack Code(Day 3)
来源:互联网 发布:js入门多久 编辑:程序博客网 时间:2024/06/06 03:37
问题:
1.6 Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place?
翻译:一张图像NxN矩阵,每个像素为4个字节,写一个方法将图像旋转90度,问可以原地处理不额外开辟新的存储空间?
1.7 Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column is set to 0.
翻译:写一个方法,对于MxN矩阵,若有一个元素为0,则将其所在的行与列的所有元素置0。
Time complexity O(M*N) and space complexity O(M+N).
还有改进的空间?(马克一下,之后再改进)
1.8 Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, s1 and s2, write code to check if s2 is a rotation of s1 using only one call to isSubstring (i.e., “waterbottle” is a rotation of “erbottlewat”).
翻译:假设你有一个方法isSubstring是可以判断一个字符串是否是另一个的字串,如给定两个字符串,s1和s2,判断s2是否是s1的旋转字符串,只能调用一次isSubstring,(例如:waterbottle是erbottlewat的旋转字符串)
2.1 Write code to remove duplicates from an unsorted linked list.
FOLLOW UP
How would you solve this problem if a temporary buffer is not allowed?
翻译:在没有排序的链表中删除重复的项,并且不允许使用临时的缓存,如何解决这个问题?
1.如果可以使用额外的存储空间,我们就可以保存一个元素的出现情况,例如使用哈希表。c++标准库里有哈希表吗?不用哈希表用数组?数组的大小和元素的范围?
- 每天坚持Crack Code(Day 3)
- 每天坚持Crack Code(Day 1)
- 每天坚持Crack Code(Day 2)
- 每天坚持Crack Code(Day 4)
- 每天坚持Crack Code(Day 5)
- 每天坚持Crack Code(Day 6)
- Crack the code interview_Q1.3
- crack the code interview1.3
- 背景颜色渐变(每天坚持一下)
- Crack the code interview_Q1.1
- Crack the code interview_Q1.2
- Crack the code interview_Q1.4
- crack the code interview1.1
- crack the code interview 1.2
- crack the code interview 1.4
- crack the code interview 1.5
- crack the code interview 1.6
- crack the code interview 1.7
- 阿里2014校园招聘 笔试题
- MVC模式浅谈
- Nginx 简单的负载均衡配置示例(转)
- 迅雷2014校园招聘笔试题
- Windows下SlikSVN的使用
- 每天坚持Crack Code(Day 3)
- HDU 4722 WA求大神指教(已经更正)
- JSP学习笔记2
- JAVA里面如何让一个线程死亡或结束
- 【科普帖】线程与进程
- PPS2013校园招聘笔试题
- Qt 命令 -qws
- webServcie 接口和http接口
- WordPress上传中文文件名或图片名乱码问题