上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 15 下一页
摘要: I/O 多路复用(I/O multiplexing) 本文对阻塞/非阻塞、同步/异步等概念进行简要区分,简单介绍了5种I/O模型,对Linux平台3种I/O复用的方式进行了比较,重点分析了 epoll 的实现。 I/O 模型 得益于Unix“一切皆文件”的设计哲学,I/O操作本身通过 read/wr 阅读全文
posted @ 2021-03-24 21:54 与MPI做斗争 阅读(115) 评论(0) 推荐(0) 编辑
摘要: 两道环形队列设计的题。 LeetCode 622. Design Circular Queue LeetCode 641. Design Circular Deque 题目描述 一道题是环形 queue 的设计,circular queue is also called "Ring Buffer"; 阅读全文
posted @ 2021-03-14 21:28 与MPI做斗争 阅读(76) 评论(0) 推荐(0) 编辑
摘要: LeetCode 上两道相似的 hash 数据结构设计题。 LeetCode 705. Design HashSet LeetCode 706. Design HashMap 题目描述 两道题题干相似,都是给出接口要求实现数据结构。两道题都做出了一些简化以降低设计难度: key / value 都用 阅读全文
posted @ 2021-03-14 20:26 与MPI做斗争 阅读(79) 评论(0) 推荐(0) 编辑
摘要: 水塘抽样 与 洗牌算法 本文介绍两个相似的问题,水塘抽样和洗牌算法。 水塘抽样(Reservoir Sampling) 水塘抽样(Reservoir Sampling)说的是这样一个问题:当内存无法完全加载时,如何从数据流或大数据集中随机选取k个样本,并保证每个样本被选取的概率相等。 典型问题出现在 阅读全文
posted @ 2021-03-12 15:53 与MPI做斗争 阅读(158) 评论(0) 推荐(0) 编辑
摘要: LeetCode 279. Perfect Squres DP 是笨办法中的高效办法,又是一道可以被好办法打败的 DP 题。 题目描述 Given a positive integer n, find the least number of perfect square numbers (for e 阅读全文
posted @ 2021-03-10 14:55 与MPI做斗争 阅读(69) 评论(0) 推荐(0) 编辑
摘要: LeetCode 1025. 除数博弈 博弈问题,非常有趣。 题目描述 Alice and Bob take turns playing a game, with Alice starting first. Initially, there is a number N on the chalkboa 阅读全文
posted @ 2021-03-10 12:52 与MPI做斗争 阅读(51) 评论(0) 推荐(0) 编辑
摘要: LeetCode 679. 24点游戏 看到一道回溯的题目,一时有点毛爪,看leetcode的讨论,竟然发现 打表 和 暴力枚举 的做法。受此启发写下了这份答案。 题目描述 You have 4 cards each containing a number from 1 to 9. You need 阅读全文
posted @ 2021-03-09 21:05 与MPI做斗争 阅读(53) 评论(0) 推荐(0) 编辑
摘要: 阿里暑期实习笔试题 阿里暑期实习的笔试,3月6日的第一场据说比较难,两道 leetcode hard题。 3.9 更新 找到问题了,问题出在 auto&& [stop, step] = q.front(); q.pop(); 这两句上,我们使用的是一个引用,但是后来这个元素被 pop 释放掉了,所以 阅读全文
posted @ 2021-03-08 18:46 与MPI做斗争 阅读(533) 评论(0) 推荐(0) 编辑
摘要: 跳跃游戏系列(LeetCode Jump Game I-V) 用到的思路包括:贪心、广搜、递归。 题目较多,就不贴原题了,点击标题直接跳转查看。 LeetCode 55. Jump Game I 这道题给出的数组元素表示当前位置最大可跳距离,问能否从第一个位置到达最后一个位置。 BFS 是会超时的, 阅读全文
posted @ 2021-03-08 12:20 与MPI做斗争 阅读(178) 评论(0) 推荐(0) 编辑
摘要: LeetCode 396. Rotate Function 一道数学题。 题目描述 Given an array of integers A and let n to be its length. Assume Bk to be an array obtained by rotating the a 阅读全文
posted @ 2021-03-04 16:08 与MPI做斗争 阅读(40) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 15 下一页