
Java
KINGHMY
人工智障炼丹师,人工自然语言处理工程师
展开
-
更简单的非递归遍历二叉树的方法
原地址 http://www.jianshu.com/p/49c8cfd07410更简单的非递归遍历二叉树的方法解决二叉树的很多问题的方案都是基于对二叉树的遍历。遍历二叉树的前序,中序,后序三大方法算是计算机科班学生必写代码了。转载 2017-01-01 21:26:10 · 643 阅读 · 0 评论 -
二叉树前序、中序、后序遍历非递归写法的透彻解析
原文地址:http://blog.youkuaiyun.com/zhangxiangdavaid/article/details/37115355在前两篇文章二叉树和二叉搜索树中已经涉及到了二叉树的三种遍历。递归写法,只要理解思想,几行代码。可是非递归写法却很不容易。这里特地总结下,透彻解析它们的非递归写法。其中,中序遍历的非递归写法最简单,后序遍历最难。我们的讨论基础是这样的:转载 2017-01-02 15:03:03 · 534 阅读 · 0 评论 -
Generate Parentheses-LeetCode
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.For example, given n = 3, a solution set is:[ "((()))", "(()())", "(())()", "()(())原创 2017-03-12 16:14:24 · 421 阅读 · 0 评论 -
Merge k Sorted Lists-LeetCode
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.题目描述:归并排序k个有序单链表。(感觉LeetCode说到排序默认即是自然会顺序,数字递增,字母按顺序)题目思路:先说一个由二路归并得来的思维简单、看似取巧实则复杂度奇高的方法:直接k路归并原创 2017-03-13 11:59:47 · 365 阅读 · 0 评论 -
Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.For example,Given 1->2->3->4, you should return the list as 2->1->4->3.Your algorithm should use only constant space. Y原创 2017-03-15 21:17:54 · 498 阅读 · 0 评论 -
Reverse Nodes in k-Group-LeetCode
Given a linked list, reverse the nodes of a linked list k at a time and return its modified list.k is a positive integer and is less than or equal to the length of the linked list. If the number o原创 2017-03-15 22:43:08 · 448 阅读 · 0 评论