摘要: 题目描述 输入一个链表,从尾到头打印链表每个节点的值。 思路1:stack 1 import java.util.ArrayList; 2 import java.util.Stack; 3 public class Solution { 4 public ArrayList<Integer> pr 阅读全文
posted @ 2017-10-29 22:11 乐乐章 阅读(117) 评论(0) 推荐(0) 编辑
摘要: Given a binary tree, return the tilt of the whole tree. The tilt of a tree node is defined as the absolute difference between the sum of all left subt 阅读全文
posted @ 2017-10-29 10:17 乐乐章 阅读(98) 评论(0) 推荐(0) 编辑
摘要: You need to construct a string consists of parenthesis and integers from a binary tree with the preorder traversing way. The null node needs to be rep 阅读全文
posted @ 2017-10-29 09:45 乐乐章 阅读(124) 评论(0) 推荐(0) 编辑
摘要: 题目描述 请实现一个函数,将一个字符串中的空格替换成“%20”。例如,当字符串为We Are Happy.则经过替换之后的字符串为We%20Are%20Happy。 思路: 从前往后替换,后面的字符要不断往后移动,要多次移动,所以效率低下,时间复杂度 O(N2)。 从后往前,先计算需要多少空间,然后 阅读全文
posted @ 2017-10-29 08:57 乐乐章 阅读(169) 评论(0) 推荐(0) 编辑