摘要: Algorithm : 做一个 leetcode 的算法题1.合并两个排序链表2.树的子结构3.二叉树的镜像4.包含Min函数的栈5.栈的压入、弹出6.二叉搜索树的后序遍历7.从上往下打印二叉树Review : 阅读并点评一篇英文技术文章Tips : 学习一个技术技巧1.什么是Mysql索引?是一种排好序可以快速查找的数据结构原文链接:https://mp.weixin.qq.com/s/8Jzv... 阅读全文
posted @ 2019-07-28 14:01 VIP丶可乐 阅读(95) 评论(0) 推荐(0) 编辑
摘要: /////////////////////////////////////////////////////////////////////////////////////// 5. 题目23 从上往下打印二叉树void PrintTreeFromTopToBottom(BinarySeachTreeNode* pRoot){ if (NULL == pRoot) { re... 阅读全文
posted @ 2019-07-28 13:46 VIP丶可乐 阅读(113) 评论(0) 推荐(0) 编辑
摘要: /////////////////////////////////////////////////////////////////////////////////////// 6. 题目24 二叉搜索树的后序遍历// 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历结果!!!/* 8 / \ 6 10 / \ / \ 5... 阅读全文
posted @ 2019-07-28 13:46 VIP丶可乐 阅读(125) 评论(0) 推荐(0) 编辑
摘要: /////////////////////////////////////////////////////////////////////////////////////// 4. 题目22 栈的压入、弹出// 输入两个整数序列,第一个整数序列表示栈的压入顺序,请判断第二个序列是否该栈的弹出序列!!!bool StackPushPopOrder(int* piPush, int* piPop, i... 阅读全文
posted @ 2019-07-28 13:45 VIP丶可乐 阅读(104) 评论(0) 推荐(0) 编辑
摘要: /////////////////////////////////////////////////////////////////////////////////////// 3. 题目21 包含Min函数的栈template class CMinInStack{public: void Push(const TYPE& value); const TYPE Pop(); co... 阅读全文
posted @ 2019-07-28 13:44 VIP丶可乐 阅读(179) 评论(0) 推荐(0) 编辑
摘要: /////////////////////////////////////////////////////////////////////////////////////// 2. 题目20 顺时针打印矩阵// 输入一个矩阵,按照从外向里以顺时针依次打印出每个数字!!!void PrintMatirxInCircle(int(*ppArray)[4], int iRows, int iColumn... 阅读全文
posted @ 2019-07-28 13:43 VIP丶可乐 阅读(149) 评论(0) 推荐(0) 编辑
摘要: ///////////////////////////////////////////////////////////////////////////////////////1. 题目19 二叉树的镜像// 请完成一个函数,输入一个二叉树,该函数输出它的镜像// 时间复杂度:O(n), 空间复杂度:O(1) --> 但是递归有一些函数形参等的消耗void MirrorOfBinaryTree(B... 阅读全文
posted @ 2019-07-28 13:42 VIP丶可乐 阅读(154) 评论(0) 推荐(0) 编辑
摘要: /////////////////////////////////////////////////////////////////////////////////////// 8. 题目18 树的子结构// 输入两颗二叉树A和B,判断B是不是A的子结构templatestruct BinaryTreeNode{ TYPE m_stValue; BinaryTreeNode* m_pLe... 阅读全文
posted @ 2019-07-28 13:40 VIP丶可乐 阅读(135) 评论(0) 推荐(0) 编辑
摘要: /////////////////////////////////////////////////////////////////////////////////////// 7. 题目17 合并两个排序链表//时间复杂度:O(n), 空间复杂度:O(1)ListNode* MergeSortedLists(ListNode* plhsHead, ListNode* prhsHead){ i... 阅读全文
posted @ 2019-07-28 13:39 VIP丶可乐 阅读(145) 评论(0) 推荐(0) 编辑
摘要: /////////////////////////////////////////////////////////////////////////////////////// 6. 题目16 反转链表//时间复杂度:O(n), 空间复杂度:O(1)ListNode* ReverseList(ListNode* pHead){ if (NULL == pHead) { re... 阅读全文
posted @ 2019-07-28 13:38 VIP丶可乐 阅读(113) 评论(0) 推荐(0) 编辑
摘要: /////////////////////////////////////////////////////////////////////////////////////// 5. 题目15 链表中倒数第K个节点//时间复杂度:O(n),空间复杂度O(n)ListNode* KthNodeFromEnd(ListNode* pNode, int k){ if (pNode == NULL |... 阅读全文
posted @ 2019-07-28 13:37 VIP丶可乐 阅读(109) 评论(0) 推荐(0) 编辑
摘要: /////////////////////////////////////////////////////////////////////////////////////// 4. 题目14 调整数组顺序使奇数位于偶数前面//方法一:时间复杂度O(n),空间复杂度O(n) 而且数据是没有顺序的!!!!void ReorderArray(int aiArray[], int iLen){ ve... 阅读全文
posted @ 2019-07-28 13:36 VIP丶可乐 阅读(115) 评论(0) 推荐(0) 编辑
摘要: /////////////////////////////////////////////////////////////////////////////////////// 2.打印1到最大的n位数// 2.1 方法一:当N很大时,会有溢出问题!!!!void Print1ToMaxOfDigits_1(int iLen){ int iNumber = 1; while (iLen ... 阅读全文
posted @ 2019-07-28 13:35 VIP丶可乐 阅读(126) 评论(0) 推荐(0) 编辑
摘要: /////////////////////////////////////////////////////////////////////////////////////// 3. 题目13 在O(1)时间删除链表节点// 平均时间复杂度:[(n-1)*O(1) + O(n)] / n ---> O(1)void DeleteListNode(ListNode** ppNode, ListNode... 阅读全文
posted @ 2019-07-28 13:35 VIP丶可乐 阅读(103) 评论(0) 推荐(0) 编辑
摘要: /////////////////////////////////////////////////////////////////////////////////////// 1. 题目11 数值的整数次方// 1.1 没有考虑负数和0的情况!!!!double Power(double dBase, int iExponent){ double dRes = 1.0; for (in... 阅读全文
posted @ 2019-07-28 13:33 VIP丶可乐 阅读(121) 评论(0) 推荐(0) 编辑
摘要: // 这种解法需要循环32次int BinaryOneNum(int iNum){#if 0 int iCount = 0; for (int i = 0; i > 1; } return iCount;}// 最优解法// 1100 --> 减一 --> 1001// 1100 & 1001 --> 1000int BinaryOneNum_2(int iN... 阅读全文
posted @ 2019-07-28 13:30 VIP丶可乐 阅读(122) 评论(0) 推荐(0) 编辑
摘要: /////////////////////////////////////////////////////////////////////////////////////////////// 13.题目九:斐波那契数列/*写一个函数,输入N,求斐波那契(Fibonacci)数列的第N项.F(n) = {0 n == 0; 1 n == 1; F(n -1... 阅读全文
posted @ 2019-07-28 13:15 VIP丶可乐 阅读(212) 评论(0) 推荐(0) 编辑
摘要: ///////////////////////////////////////////////////////////////////////////////////////////////12. 题目八:旋转数组的最小数字int RotatedBinarySearchMinNum(int aiArray[], int iLen){ int iLeft = 0; int iMid = ... 阅读全文
posted @ 2019-07-28 13:14 VIP丶可乐 阅读(109) 评论(0) 推荐(0) 编辑
摘要: ////////////////////////////////////////////////////////////////////////////////////// 10.题目七:用两个栈实现队列// 题目:用两个栈实现一个队列,队列的声明如下:template class CQueue{public: CQueue(){} ~CQueue(){} void Append... 阅读全文
posted @ 2019-07-28 13:13 VIP丶可乐 阅读(107) 评论(0) 推荐(0) 编辑
摘要: ///////////////////////////////////////////////////////////////////////////////////////// // 9.题目六:重建二叉树// 题目:输入某二叉树的前序遍历和中序遍历的结果,请重建出改二叉树struct BinaryTreeNode{ int m_iValue; BinaryTreeNode* m_p... 阅读全文
posted @ 2019-07-28 13:12 VIP丶可乐 阅读(135) 评论(0) 推荐(0) 编辑