![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
《Cracking the Coding Intervie》
fxf1012
这个作者很懒,什么都没留下…
展开
-
《CTCI》1.1 字符串的所有字符是否全部相同
《CITI》1.1 P1081.1 Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures?原创 2015-04-24 19:42:17 · 321 阅读 · 0 评论 -
《CTCI》2.7 检查链表是否为回文
《CITI》P12 链表题目:2.7 Implement a function to check if a linked list is a palindrome原创 2015-04-25 11:17:45 · 289 阅读 · 0 评论 -
《CTCI》2.3 删除链表某结点
《CITI》P12 链表题目:2.3 Implement an algorithm to delete a node in the middle of a singly linked list, given only access to that node.原创 2015-04-25 11:06:21 · 258 阅读 · 0 评论 -
《CTCI》2.1 移除未排序链表中的重复结点
《CITI》P1172 链表题目:2.1 Write code to remove duplicates from an unsorted linked list. FOLLOW UP How would you solve this problem if a temporary buffer is not allowed?原创 2015-04-25 11:01:34 · 467 阅读 · 0 评论 -
《CTCI》2.5 链表表示的整数求和
《CITI》P1232 链表题目:2.5 You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1 ‘s digit is at the head of the l原创 2015-04-25 11:09:56 · 368 阅读 · 0 评论 -
《CTCI》3.5 用两个栈实现队列
《CTCI》 P1423 栈与队列题目3.5 实现一个MyQueue类,该类用两个栈来实现一个队列。解答#include <stack>template <typename T> class queue{public: void push(const T& val); void pop(); const T& front(); const T& back();原创 2015-05-08 21:52:44 · 331 阅读 · 0 评论 -
《CTCI》3.7 “猫狗”队列
《CITI》P1453 栈与队列题目:3.7 An animal shelter holds only dogs and cats, and operates on a strictly “first in, first out” basis. People must adopt either the “oldest” (based on arrival time) of all animals a原创 2015-04-28 11:22:22 · 363 阅读 · 0 评论 -
《CTCI》3.6 用两个栈实现排序栈
《CITI》P1433 栈与队列题目:3.6 Write a program to sort a stack in ascending order (with biggest items on top). You may use at most one additional stack to hold items, but you may not copy the elements into any原创 2015-04-28 11:21:26 · 402 阅读 · 0 评论 -
《CTCI》3.4 汉诺塔游戏
《CTCI》 P1403 栈与队列题目3.4 In the classic problem of the Towers of Hanoi, you have 3 towers and N disks of different sizes which can slide onto any tower. The puzzle starts with disks sorted in ascending o原创 2015-05-07 17:05:18 · 440 阅读 · 0 评论 -
《CTCI》2.2 单项链表中倒数第k个结点
《CITI》P1182 链表题目:2.2 Implement an algorithm to find the kth to last element of a singly linked list.原创 2015-04-25 11:04:39 · 315 阅读 · 0 评论 -
《CTCI》2.4 划分链表
《CITI》P1212 链表题目:2.4 Write code to partition a linked list around a value x, such that all nodes less than x come before alt nodes greater than or equal to x.原创 2015-04-25 11:07:58 · 300 阅读 · 0 评论 -
《CTCI》3.2 包含min方法的栈
《CITI》P1353 栈与队列题目:3.2 How would you design a stack which, in addition to push and pop, also has a function min which returns the minimum element? Push, pop and min should all operate in 0(1) time原创 2015-04-24 19:50:19 · 245 阅读 · 0 评论 -
《CTCI》3.1 一个数组实现多个栈
《CITI》P1083 栈与队列题目:3.1 Describe how you could use a single array to implement three stacks.解答://3.1 Describe how you could use a single array to implement three stacks.#include <iostream>#include <win原创 2015-04-24 17:22:57 · 313 阅读 · 0 评论 -
《CTCI》1.2 反转null结尾的字符串
《CITI》P1091 数组与字符串题目:1.2 Implement a function void reverse (char* str) in Cor C++ which reverses a null-terminated string.原创 2015-04-24 21:23:30 · 351 阅读 · 0 评论 -
《CTCI》1.3 变位词
《CITI》P1091 数组与字符串题目:1.3 Given two strings, write a method to decide if one is a permutation of the other.链接anagram (变位词)原创 2015-04-24 22:11:16 · 261 阅读 · 0 评论 -
《CTCI》1.4 替换字符串中的空格为“%20”
《CITI》P1111 数组与字符串题目:1.4 Write a method to replace all spaces in a string with ‘%20’. You may assume that the string has sufficient space at the end of the string to hold the additional characters, and原创 2015-04-24 22:14:08 · 313 阅读 · 0 评论 -
《CTCI》1.5 字符串“压缩”
《CITI》P1121 数组与字符串题目:1.5 Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2blc5a3. If the “compressed” s原创 2015-04-24 22:16:39 · 432 阅读 · 0 评论 -
《CTCI》1.6 旋转二维数组
《CITI》P1141 数组与字符串题目:1.6 Given an image represented by an NxN matrix, where each pixel in the image is 4 bytes, write a method to rotate the image by 90 degrees. Can you do this in place?原创 2015-04-24 22:18:42 · 217 阅读 · 0 评论 -
《CTCI》1.7 二维数组的含0元素所在行列清零
《CITI》P1151 数组与字符串题目:1.7 Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column are set to 0.原创 2015-04-24 22:20:20 · 852 阅读 · 0 评论 -
《CTCI》1.8 调用一次isSubstring判断旋转字符串
《CITI》P1161 数组与字符串题目:1.8 Assume you have a method isSubstring which checks if one word is a substring of another. Given two strings, si and s2, write code to check Ifs2 is a rotation of si using only o原创 2015-04-24 22:23:49 · 548 阅读 · 0 评论 -
《CTCI》2.6 寻找有环链表的开头结点
《CITI》P1262 链表题目:2.6 Given a circular linked list, implement an algorithm which returns the node at the beginning of the loop.原创 2015-04-25 11:17:05 · 297 阅读 · 0 评论 -
《CTCI》3.3 栈之栈
《CITI》P1373 栈与队列题目:3.3 Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in real life, we would likely start a new stack when the previous stack exceeds some原创 2015-04-28 11:14:19 · 441 阅读 · 0 评论