Fork me on GitHub
摘要: Given two binary trees, write a function to check if they are equal or not. Two binary trees are considered equal if they are structurally identical a 阅读全文
posted @ 2017-02-25 17:40 hellowOOOrld 阅读(197) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the postorder traversal of its nodes' values. For example: Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [3,2,1]. Note: Re 阅读全文
posted @ 2017-02-25 16:42 hellowOOOrld 阅读(196) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the preorder traversal of its nodes' values. Given binary tree {1,#,2,3}, 1 \ 2 / 3 return [1,2,3]. Note: Recursive soluti 阅读全文
posted @ 2017-02-25 15:21 hellowOOOrld 阅读(140) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list using insertion sort. 写的思路其实很朴素: 1.先将原链表一个结点摘下来。 2.插入到有序的新链表里的合适位置。 3.循环1、2步骤,直到原链表所有结点遍历完毕。 时间复杂度为O(n2),空间复杂度为O(1)。 阅读全文
posted @ 2017-02-24 22:58 hellowOOOrld 阅读(208) 评论(0) 推荐(0) 编辑
摘要: Sort a linked list in O(n log n) time using constant space complexity. 利用归并排序的思想,递归合并两个有序的链表。 首先将链表递归分成两部分,直到只有一个结点为止,然后从底到上合并链表。 当然是学习大牛代码后写出的,如下: 阅读全文
posted @ 2017-02-24 19:45 hellowOOOrld 阅读(160) 评论(0) 推荐(0) 编辑
摘要: leetcode-149-Max Points on a Line 阅读全文
posted @ 2017-02-24 13:06 hellowOOOrld 阅读(255) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, every element appears twice except for one. Find that single one. Note: Your algorithm should have a linear runtime comple 阅读全文
posted @ 2017-02-23 19:36 hellowOOOrld 阅读(147) 评论(0) 推荐(0) 编辑
摘要: You are given two non - empty linked lists representing two non - negative integers. The digits are stored in reverse order and each of their nodes co 阅读全文
posted @ 2017-02-23 16:38 hellowOOOrld 阅读(158) 评论(0) 推荐(0) 编辑
摘要: Evaluate the value of an arithmetic expression in Reverse Polish Notation. Valid operators are +, -, *, /. Each operand may be an integer or another e 阅读全文
posted @ 2017-02-23 12:34 hellowOOOrld 阅读(219) 评论(0) 推荐(0) 编辑
摘要: Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have ex 阅读全文
posted @ 2017-02-22 22:24 hellowOOOrld 阅读(167) 评论(0) 推荐(0) 编辑