![](https://img-blog.csdnimg.cn/20201014180756916.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
剑指offer
数据小冰
好记性不如烂笔头,学习、实践、总结,成为更好的自己。
展开
-
【leetcode】Minimum Depth of Binary Tree
题目描述 Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. 题目要求: 求二叉树的最短从根节点到叶子节点的深度,这道原创 2016-04-30 09:57:29 · 335 阅读 · 0 评论 -
二维数组中的查找
题目:在一个二维数组中,每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。 分析:数组左上角的元素最小,右下角的元素最大,原创 2016-08-15 20:33:47 · 627 阅读 · 0 评论 -
【剑指Offer】从尾到头打印链表
题目:输入一个链表,从尾到头打印链表每个节点的值。 vector printListFromTailToHead(struct ListNode* head) { stack s; vector v; while(head){ s.push(head->val); head=head->next;原创 2016-08-16 19:08:32 · 440 阅读 · 0 评论 -
【剑指Offer】替换空格
题目:请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。void replaceSpace(char *str,int length) { char *ch=(char *)malloc(sizeof(char)*length); strcpy(ch,str);原创 2016-08-16 18:51:53 · 470 阅读 · 0 评论