数组中出现次数超过一半的数字

摘要: // 5.4.数组中出现次数超过一半的数字#include "stdafx.h"using namespace std;#include <string>#include <vector>#include <map>class Solution{public: //建立哈希表法//时间O(n),空间 阅读全文
posted @ 2020-04-19 16:03 心中日月007 阅读(94) 评论(0) 推荐(0) 编辑

调整数组顺序使奇数位于偶数前面

摘要: #include "stdafx.h"using namespace std;#include <string>#include <vector>#include <deque>class Solution{public: Solution(); ~Solution(); // [3, 4, 5, 阅读全文
posted @ 2020-04-19 15:50 心中日月007 阅读(102) 评论(0) 推荐(0) 编辑

// 二维数组查找

摘要: // 二维数组查找#include "stdafx.h"using namespace std;#include <string>#include <vector>class Solution {public: bool Find(int target, vector<vector<int> > a 阅读全文
posted @ 2020-04-19 14:14 心中日月007 阅读(105) 评论(0) 推荐(0) 编辑

反转链表

摘要: #include "stdafx.h"#include <string>using namespace std;#include <vector>#include <stack>typedef struct tag_listnode{ int data; struct tag_listnode *n 阅读全文
posted @ 2020-04-18 21:11 心中日月007 阅读(94) 评论(0) 推荐(0) 编辑

从尾到头打印链表

摘要: #include "stdafx.h"#include <string>using namespace std;#include <vector>#include <stack>typedef struct tag_listnode{ int data; struct tag_listnode *n 阅读全文
posted @ 2020-04-18 21:00 心中日月007 阅读(116) 评论(0) 推荐(0) 编辑

栈的压入、弹出序列

摘要: 输入两个整数序列,第一个序列表示栈的压入顺序,请判断第二个序列是否为该栈的弹出顺序。假设压入栈的所有数字均不相等。例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列对应的一个弹出序列,但4,3,5,1,2就不可能是该压栈序列的弹出序列。(注意:这两个序列的长度是相等的) 阅读全文
posted @ 2020-04-17 22:32 心中日月007 阅读(106) 评论(0) 推荐(0) 编辑

翻转单词顺序序列

摘要: 例如,“student. a am I”。应该是“I am a student.” // ConsoleApplication3.cpp : Defines the entry point for the console application.//#include "stdafx.h"#inclu 阅读全文
posted @ 2020-04-14 23:45 心中日月007 阅读(148) 评论(0) 推荐(0) 编辑

左旋转字符串

摘要: #include "stdafx.h"#include "string"using namespace std;class MyClass{public: MyClass(); ~MyClass(); string leftRoteStr(string str, int patern) { int 阅读全文
posted @ 2020-04-14 23:05 心中日月007 阅读(91) 评论(0) 推荐(0) 编辑

查找第一个只出现一次的字符

摘要: #include "stdafx.h"#include <string>using namespace std;#include <vector>#include <map>class Solution{public: int find_right_char(string str) { int st 阅读全文
posted @ 2020-04-14 23:04 心中日月007 阅读(123) 评论(0) 推荐(0) 编辑