02 2020 档案

摘要:Given an m x n matrix of non-negative integers representing the height of each unit cell in a continent, the "Pacific ocean" touches the left and top 阅读全文
posted @ 2020-02-24 23:12 强威 阅读(163) 评论(0) 推荐(0) 编辑
摘要:1.哈希表 2.优先队列实现 3.堆排序(面试中堆的问题经常出现) 4.二叉搜索树的特征,查找和插入的时间复杂度 5.为什么说二叉搜索树有时会不稳定,如何改进?(可能会退化为链表;改进为平衡二叉查找树) 6.AVL树大概的调整过程;(左旋右旋) 7.红黑树的特征以及大概的调整过程 8.海量数据排序 阅读全文
posted @ 2020-02-20 18:42 强威 阅读(147) 评论(0) 推荐(0) 编辑
摘要:1.突破 const 的限制 class Test { public: Test() = default; Test(unsigned int times):times(times){ } ~Test() = default; void printOut() const { cout << "out 阅读全文
posted @ 2020-02-19 19:53 强威 阅读(232) 评论(0) 推荐(0) 编辑
摘要:1.如何查看内存空间?如何查看磁盘空间? (free; df -h) 2.如何查看进程? 3.一个文件"ip.txt",有两个字段ip(第一列)和访问时间(第二列),找出访问次数最多的ip awk '{ips[$1]++;} END {for(ip in ips) printf("%s\t%d\n" 阅读全文
posted @ 2020-02-17 18:21 强威 阅读(163) 评论(0) 推荐(0) 编辑
摘要:1.IO高并发如何实现? 2.线程与进程的区别? 3.为什么进程的切换开销比线程大? 4.信号量机制;(整型、记录型、AND型、信号量集) 5.锁机制;(互斥锁、自旋锁) 6.cache一致性 7.虚拟内存与物理内存的区别 8.死锁 9.进程什么时候由用户态转化为内核态?(系统调用、中断、陷入) 1 阅读全文
posted @ 2020-02-17 18:20 强威 阅读(256) 评论(0) 推荐(0) 编辑
摘要:1.数据库中的事务以及一致性问题 2.数据库的底层实现(B+树,跳表) 3.索引是什么,如何实现? 4.sql引擎有哪些?MyISAM和InnoDB的区别?B+树与B树的区别? 5.MySQL的引擎有哪些?区别?底层实现?索引? 阅读全文
posted @ 2020-02-17 18:17 强威 阅读(127) 评论(0) 推荐(0) 编辑
摘要:还记得c++ primer一书中说过,成员函数有一个隐藏的this指针作为参数。 这里的com 成员函数看似有两个参数,但是还有一个隐藏的this指针参数,所以它是有三个参数的,当sort进行调用时会造成参数不匹配,编译错误。 但是当把com函数声明为静态成员函数时,它就没有了隐藏的this指针参数 阅读全文
posted @ 2020-02-13 22:28 强威 阅读(393) 评论(0) 推荐(0) 编辑
摘要:1.在main函数前调用函数 2.new/delete, new[]/delete[], malloc, free的联系与区别 malloc/free 是动态内存管理的入口,从动态内存里申请处一块内存给我们使用,但是这块内存并没有被初始化,在使用之前,我们还需要对这块内存进行手动的初始化。对于自己定 阅读全文
posted @ 2020-02-13 10:52 强威 阅读(234) 评论(0) 推荐(0) 编辑
摘要:1.TCP为什么可靠? 重传机制 拥塞控制 流量控制(TCP滑动窗口) 序列号与确认序列号 2.web页面请求过程:在浏览器中输入一个网址到获得一个页面,这个过程中有用到哪些协议? (DNS + HTTP + TCP + IP + ARP;这个问题基本上可以将所有的网络协议串起来,是一个很好的问题, 阅读全文
posted @ 2020-02-13 10:49 强威 阅读(210) 评论(0) 推荐(0) 编辑
摘要:构建二叉树: 增加节点: 删除节点: 查询节点: 1.先序遍历 /* 递归版前序遍历 */ void Tree::preOrderWithRecursive(ListNode* root) { if (root == nullptr)return; std::cout << root->val << 阅读全文
posted @ 2020-02-12 22:41 强威 阅读(130) 评论(0) 推荐(0) 编辑
摘要:Given an array with n objects colored red, white or blue, sort them in-place so that objects of the same color are adjacent, with the colors in the or 阅读全文
posted @ 2020-02-11 20:01 强威 阅读(114) 评论(0) 推荐(0) 编辑
摘要:桶排序是将待排序集合中处于同一个值域的元素存入同一个桶中,也就是根据元素值特性将集合拆分为多个区域,则拆分后形成的多个桶,从值域上看是处于有序状态的。对每个桶中元素进行排序,则所有桶中元素构成的集合是已排序的。 快速排序是将集合拆分为两个值域,这里称为两个桶,再分别对两个桶进行排序,最终完成排序。桶 阅读全文
posted @ 2020-02-11 15:24 强威 阅读(226) 评论(0) 推荐(0) 编辑
摘要:堆排序代码: #pragma once #include <vector> class HeapSort { public: void sort(std::vector<int>& seq) { // 构建大顶堆 for (int i = seq.size() / 2 - 1; i >= 0; -- 阅读全文
posted @ 2020-02-11 14:36 强威 阅读(192) 评论(0) 推荐(0) 编辑
摘要:快速排序 正如它的名字一样,是一种效率较高的排序方法,面试中也经常出现,正常情况下时间复杂度为 O(n * logn)。但是快排是一种不稳定排序算法,排序过程中会打乱元素顺序。 快排的核心是partition算法,partition算法步骤: 选取一个元素作为pivot。 将小于pivot的元素放在 阅读全文
posted @ 2020-02-11 14:35 强威 阅读(189) 评论(0) 推荐(0) 编辑
摘要:1.非常量成员函数返回非常量 *this,常量成员函数返回常量 *this,指向常量对象。 2.重载函数必须参数数量或者类型不同吗? 答案是:否。还存在一种const重载; Person.h #pragma once #include <iostream> #include <string> #in 阅读全文
posted @ 2020-02-10 20:26 强威 阅读(287) 评论(0) 推荐(0) 编辑
摘要:1.修饰变量 const int i = 0; // i 为常量,不可修改 const int* p = &i; // 指向常量的指针 int* const p = &i; // 指针为常量,指向i不可修改 const int &r = i; // 常量引用,不可通过r修改i typedef int 阅读全文
posted @ 2020-02-10 17:56 强威 阅读(164) 评论(0) 推荐(0) 编辑
摘要:比较简单的一个题,但是浪费了很多时间,主要是因为刚开始的思路有一点漏洞。 Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. Exa 阅读全文
posted @ 2020-02-09 22:16 强威 阅读(169) 评论(0) 推荐(0) 编辑
摘要:C++实现trid class TrieNode{ public: TrieNode():End(false), R(26){ links.resize(R); } void setEnd(){ End = true; } bool isEnd(){ return End; } bool conta 阅读全文
posted @ 2020-02-09 14:36 强威 阅读(174) 评论(0) 推荐(0) 编辑
摘要:单调队列分为递增队列和递减队列,一般用来求某个固定长度(例如:滑动窗口的最值)序列中的最大/最小值。 对于递增队列,队首元素就是最小值。 对于递减队列,队首元素就是最大值。 1.递增队列(队列首尾最小值) if(q.empty()) q.push_back(A[i]); else if(q.back 阅读全文
posted @ 2020-02-09 13:08 强威 阅读(301) 评论(0) 推荐(0) 编辑
摘要:Given an input string (s) and a pattern (p), implement regular expression matching with support for '.' and '*'. '.' Matches any single character. '*' 阅读全文
posted @ 2020-02-08 17:45 强威 阅读(133) 评论(0) 推荐(0) 编辑
摘要:1.归 ListNode* sortList(ListNode* head) { if (head == nullptr || head->next == nullptr) return head; // 1.将待排序序列分为两部分 ListNode* pre = nullptr, *slow = 阅读全文
posted @ 2020-02-07 22:36 强威 阅读(237) 评论(0) 推荐(0) 编辑
摘要:Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2->1->3 Output: 1->2->3->4 Example 2: Input: -1->5->3->4-> 阅读全文
posted @ 2020-02-07 22:17 强威 阅读(164) 评论(0) 推荐(0) 编辑
摘要:2020.2.6 494. Target Sum 我用的递归暴力解决的笨方法,本题有一种动态规划的好方法,但不能理解。待学习; 博客链接:https://www.cnblogs.com/qiang-wei/p/12271263.html 题目链接:https://leetcode.com/probl 阅读全文
posted @ 2020-02-06 23:19 强威 阅读(119) 评论(0) 推荐(0) 编辑
摘要:Given an array of integers and an integer k, you need to find the total number of continuous subarrays whose sum equals to k. Example 1: Input:nums = 阅读全文
posted @ 2020-02-06 23:18 强威 阅读(150) 评论(0) 推荐(0) 编辑
摘要:You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For each integer, you should choose o 阅读全文
posted @ 2020-02-06 22:24 强威 阅读(160) 评论(0) 推荐(0) 编辑
摘要:Given a non-empty array of integers, return the k most frequent elements. Example 1: Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2: Input 阅读全文
posted @ 2020-02-06 13:15 强威 阅读(113) 评论(0) 推荐(0) 编辑
摘要:Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" Output: 阅读全文
posted @ 2020-02-04 20:57 强威 阅读(198) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示