摘要: You are given annxn2D matrix representing an image.Rotate the image by 90 degrees (clockwise).Follow up:Could you do this in-place?用了最笨的办法。就地转的话应该是一圈一... 阅读全文
posted @ 2014-04-06 22:24 Eason Liu 阅读(1850) 评论(0) 推荐(0) 编辑
摘要: A message containing letters fromA-Zis being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message containing digits, determine the total number of ways to decode it.For example,Given encoded message"12", it cou 阅读全文
posted @ 2014-04-06 14:21 Eason Liu 阅读(270) 评论(0) 推荐(0) 编辑
摘要: 题目描述:数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字。例如输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}。由于数字2在数组中出现了5次,超过数组长度的一半,因此输出2。输入:每个测试案例包括2行:第一行输入一个整数n(1 2 #include 3 using namespace std; 4 5 int main() 6 { 7 int n; 8 long a[100005]; 9 10 while (cin >> n) {11 for (int i=0; i > a[i];13 }14 ... 阅读全文
posted @ 2014-04-06 13:01 Eason Liu 阅读(407) 评论(0) 推荐(0) 编辑
摘要: Given a 2D board and a word, find if the word exists in the grid.The word can be constructed from letters of sequentially adjacent cell, where "adjace... 阅读全文
posted @ 2014-04-06 01:54 Eason Liu 阅读(2417) 评论(0) 推荐(0) 编辑
摘要: The count-and-say sequence is the sequence of integers beginning as follows:1, 11, 21, 1211, 111221, ...1is read off as"one 1"or11.11is read off as"two 1s"or21.21is read off as"one 2, thenone 1"or1211.Given an integern, generate thenthsequence.Note: The sequence of inte 阅读全文
posted @ 2014-04-06 00:29 Eason Liu 阅读(198) 评论(0) 推荐(0) 编辑