
算法
_东方既白_
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
腾讯面试题(九度)——面积最大的全1子矩阵
题目地址:http://ac.jobdu.com/problem.php?pid=1497 题目描述: 在一个M * N的矩阵中,所有的元素只有0和1,从这个矩阵中找出一个面积最大的全1子矩阵,所谓最大是指元素1的个数最多。 输入: 输入可能包含多个测试样例。 对于每个测试案例,输入的第一行是两个整数m、n(1 矩阵共有m行,每行有n个整数,分别是0或1原创 2014-01-07 14:50:00 · 1816 阅读 · 0 评论 -
浙大2012机试题——Sharing
原题地址:http://ac.jobdu.com/problem.php?pid=1468 题目描述: To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words s原创 2014-01-08 16:24:33 · 724 阅读 · 0 评论 -
华为- 排号机(OJ通过)
题目很简单,用c++的vector,list等均可 #include <iostream> #include <string> #include <list> #include <algorithm> using namespace std; struct node{ int num; bool vip; }; list<st...原创 2014-09-03 13:05:09 · 729 阅读 · 0 评论 -
单链表排序O(nlogn),O(1)
题目来自leetcode:Sort a linked list inO(nlogn) time using constant space complexity. 快速排序平均复杂度是O(nlogn),但最坏的时候是O(n^2),不符合要求。考虑采用归并排序,注意空间复杂度为O(1)。 struct ListNode { int val; ListNode *...原创 2014-09-07 13:29:55 · 1347 阅读 · 0 评论 -
华为-翻译电话号码
例如输入:OneTwoThree 输出:123 输入:OneTwoDoubleTwo 输出:1222 输入:1Two2 输出:ERROR 输入:DoubleDoubleTwo 输出:ERROR 有空格,非法字符,两个Double相连,Double位于最后一个单词 都错误 本题基本不涉及复杂算法,理清思路,不要忘记关键位置的判断 const string s[11]...原创 2014-09-10 12:10:51 · 923 阅读 · 0 评论 -
华为-洞穴逃生(OJ通过)
// 贪心算法,关键在贪心决策 #include <iostream> #include <string> using namespace std; const int speed_len = 17; const int move_len = 60; const int basic_m = 10; const int rest_m = 4; const string s...原创 2014-09-02 14:40:11 · 743 阅读 · 0 评论 -
华为-亮着电灯的盏数(不超时)
#include <iostream> using namespace std; const int max_num = 65536; int main() { int data[max_num]={0}; data[0] = 0; data[1] = 1; for(int i=2;i< max_num; ++i){ for(int j=2;j<ma...原创 2014-09-02 12:16:26 · 777 阅读 · 0 评论