工作
玄蛰
心中一壶酒,手上一把吉他,座前一台电脑,便是江湖
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
2021-07-17烦烦烦
方法原创 2021-07-17 13:37:51 · 163 阅读 · 0 评论 -
C++面试——最小的K个数(LeetCode 面试题40)
最小的K个数 输入整数数组 arr ,找出其中最小的 k 个数。例如,输入4、5、1、6、2、7、3、8这8个数字,则最小的4个数字是1、2、3、4。 示例 **输入:**arr = [0,1,2,1], k = 1 输出:[1,2] 或者 [2,1] 快速排序 class Solution { public: int Paration(vector<int>&...原创 2020-04-21 10:22:38 · 378 阅读 · 0 评论 -
C++面试题——字符串
求两个字符串最长公共字串 #include<iostream> #include<string> using namespace std; int main() { string a, b; while (cin >> a >> b) { if (b.size() < a.size()) { swap(a, b); } ...原创 2020-04-21 10:03:18 · 287 阅读 · 0 评论 -
C++面试题——数组
一个长度为N的整形数组,数组中每个元素的取值范围是[0,n-1],判断该数组否有重复的数 #include<iostream> using namespace std; bool IsDuplicateNumber(int *array, int n) { for (int i = 0; i<n; i++) { if (array[i] != i) { if ...原创 2020-04-21 10:02:09 · 618 阅读 · 0 评论 -
C++堆栈
用两个栈实现一个队列 #include<iostream> #include<stack> using namespace std; class Solution { private: stack<int> s1; stack<int> s2; public: int pop() { int x; if (s2.empty()) { ...原创 2020-04-21 10:03:40 · 186 阅读 · 0 评论 -
C++面试题——字符串中第一个不重复字符
字符串中第一个不重复字符 map版本 #include<iostream> #include<string> #include<map> using namespace std; int main() { string str; map<char, int> m; cin >> str; for (int i = 0; i &l...原创 2020-04-21 10:02:21 · 464 阅读 · 0 评论 -
C++面试题——括号匹配
括号匹配 #include<iostream> #include<stack> #include<string> using namespace std; int main() { string str; stack<char> s; while (cin >> str) { for (int i = 0; i < st...原创 2020-04-21 10:03:58 · 232 阅读 · 0 评论 -
C++面试——链表
链表逆序 #include<iostream> using namespace std; struct ListNode { int data; ListNode* next; }; ListNode * reverseList(ListNode* head) { ListNode *p, *q, *t=nullptr; p = head; if (p->next ...原创 2020-04-21 10:04:13 · 248 阅读 · 0 评论 -
C++面试——排序
C++链表逆序 #include<iostream> using namespace std; struct ListNode { int data; ListNode* next; }; void printList(ListNode* head) { ListNode *p; p = head->next; while (p != NULL) { cou...原创 2020-04-21 10:01:03 · 252 阅读 · 0 评论 -
华为研发工程师笔试编程题
递归算法 #include<stdio.h> int fun(int n) { if(n==1) return 0; if(n==2) return 1; return fun(n/3+n%3)+n/3; } int main() { int n; while(scanf("%d",&n)){ if(n==0)...原创 2019-09-04 15:23:09 · 3721 阅读 · 0 评论
分享