- 博客(5)
- 资源 (3)
- 收藏
- 关注
原创 华为-翻译电话号码
例如输入:OneTwoThree 输出:123输入:OneTwoDoubleTwo 输出:1222输入:1Two2 输出:ERROR输入:DoubleDoubleTwo 输出:ERROR有空格,非法字符,两个Double相连,Double位于最后一个单词 都错误本题基本不涉及复杂算法,理清思路,不要忘记关键位置的判断const string s[11]...
2014-09-10 12:10:51 831
原创 单链表排序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 1223
原创 华为- 排号机(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 658
原创 华为-洞穴逃生(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 658
原创 华为-亮着电灯的盏数(不超时)
#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 698
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人