![](https://img-blog.csdnimg.cn/20200304000013222.jpg?x-oss-process=image/resize,m_fixed,h_224,w_224)
程序员面试金典
LeetCode官网的题库
ACTIM__
ACTIM
展开
-
【程序员面试金典】面试题62. 圆圈中最后剩下的数字(模运算)
1. 题目 2. 思路 最优子问题: n 个数时,第一个删除的数的位置应当是 m%n (从零开始) 设 n-1 时,最后剩余的数的位置为 x (从零开始) n 个数时,删除第一个数后,剩余 n-1 个数,并从 m%n 开始进行删除,最后剩余的数为 (m%n + x) % n PS: (m%n + x) % n < x (因为 (x + n) % n = x, 而 m%n < ...原创 2020-04-01 01:03:20 · 484 阅读 · 0 评论 -
【程序员面试金典】面试题 01.06. 字符串压缩(c++字符串拼接)
题目 解题思路 话说c++的字符串拼接真麻烦,话说+=和java中一样的StringBuffer吗?? 代码 class Solution { public: string compressString(string S) { string ans = ""; char temp = S[0]; int count = 1; ...原创 2020-03-16 22:57:59 · 235 阅读 · 0 评论 -
【程序员面试金典】面试题 10.01. 合并排序的数组
解题思路 合并排序没什么好说的。。。 代码 class Solution { public: void merge(vector<int>& A, int m, vector<int>& B, int n) { int i = 0; // A位置游标 int j = 0; // B位置游标 int k ...原创 2020-03-03 23:43:40 · 136 阅读 · 0 评论