
算法
峻峰飞阳
每一分钟让思维跳跃驰骋,多警醒,少麻木,多联想,少沉思,多类比,少钻尖,多读书,多总结。
展开
-
C++经典面试算法题
#include <assert.h>#include <string.h>#include <stack>//1.实现strcpy. char* MyStrCpy( char *pDest, const char *pSrc ) { if( nullptr == pDest || nullptr == pSrc ) ...转载 2019-07-11 15:25:03 · 680 阅读 · 0 评论 -
按从左到右顺序加载二叉树和打印二叉树 (C++)
从配置数组中加载二叉树,例如:数组 [3, 9, 20, NULL, NULL, 15, 7],NULL代表节点不存在,按照这个假设,二叉树的节点数据不能为0.此数组对应的二叉树是 3 / \ 9 20 / \ 15 7从上到下,左右到右打印改二叉树,结果为[3, 9, 20, 15, 7],程序如下:#include<iostre...原创 2019-08-13 21:03:45 · 371 阅读 · 0 评论 -
二叉树非递归遍历
//非递归先序遍历void preorderTraverse(TreeNode* root){ stack<TreeNode*> Stack; if(!root) { printf("空树!\n"); return; } TreeNode* node = root; while (node || !...原创 2019-08-14 16:52:51 · 173 阅读 · 0 评论 -
查找最长不重复的子字符串 (C语言版)
#include <stdio.h>#include <string.h>#include <stdlib.h>int main(){ const char* str = "abdafgkfbcdakpy"; int hash[256] = { 0 }; const char* maxStr = str; int m...原创 2019-08-12 22:51:22 · 2020 阅读 · 1 评论