2014-05-01 01:00 题目链接 原题: Given a matrix with 's. What is the maximum area of the rectangle. In . How: If you see above the . 题目:给定一个‘0’.‘1’构成的矩阵,找出其中全部由‘1’构成的子矩阵中面积最大的一个. 解法:这是Leetcode上有的题目,请参考我的题解LeetCode - Maximal Rectangle. 代码: // http://www.care…
2014-05-02 10:47 题目链接 原题: Given an unordered array of positive integers, create an algorithm that makes sure no group of integers of size bigger than M have the same integers. Input: ,,,,,,,, M = Output: ,,,,,,,, 题目:给定一个未排序的长度为N的整数数组,和一个正整数M.请设计算法,将N…
2014-05-02 10:40 题目链接 原题: Sink Zero in Binary Tree. Swap zero value of a node with non-zero value of one of its descendants so that no node with value zero could be parent of node with non-zero. 题目:把二叉树中的值为0的节点尽量往下沉,保证所有值为0的节点绝不会有非0的子节点. 解法:我写的算法是O(n…
2014-05-02 10:07 题目链接 原题: Mapping ' = 'A','B','C' ' = 'D','E','F' ... ' = input: output :ouput = [AAD, BBD, CCD, AAE, AAF, BBE, BBF, CCE, CCF] 题目:电话的数字按键和字母有个映射关系,给定一串数字,请给出所有可能的字符映射方式. 解法:此人也不给个描述,搞的下面一堆人来猜题意.这个题目的意思是说,对于给定的数字串,有多少种不同的映射方式.像“112” ->…
2014-05-02 09:59 题目链接 原题: Group Anagrams input = ["star, astr, car, rac, st"] output = [["star, astr"],["car","rac"],["st"]); 题目:给定一堆字符串,设法把anagram都排在一起. 解法:自定义一个comparator,互为anagram的两个字符串在排好序以后是相同的.根据这个规则…
2014-05-02 09:54 题目链接 原题: You have two numbers decomposed in binary representation, write a function that sums them and returns the result. Input: , Output: 题目:做二进制加法. 解法:字符串就行了,不需要额外开辟数组.string对象本身就是一个vector,也就是一个数组喽. 代码: // http://www.careercup.com…
2014-05-02 09:40 题目链接 原题: Given a number N, write a program that returns all possible combinations of numbers that add up to N, =N) For example, ,,,},{,,},{,},{,}} 题目:给定一个正整数N,求出所有的由正整数加起来等于N的可能组合(加数保持升序).比如N = 4的时候,结果是{{1,1,1,1},{1,1,2},{2,2},{1,3}}…
2014-05-02 08:29 题目链接 原题: Write a function for retrieving the total number of substring palindromes. For example the input is 'abba' then the possible palindromes= a, b, b, a, bb, abba So the result . Updated at //: After the interview I got know tha…
2014-05-02 07:49 题目链接 原题: Given a set of n points (coordinate in 2d plane) within a rectangular space, find out a line (ax+by=c), from which the sum of the perpendicular distances of all the points will be minimum. This can has a general usecase like…
2014-05-02 07:37 题目链接 原题: // merge sorted arrays 'a' and 'b', each with 'length' elements, // in-place into 'b' to form a sorted result. assume that 'b' // has 2*length allocated space. // e.g. a = [1, 3, 5], b = [2, 4, 6] => b = [1, 2, 3, 4, 5, 6] /…