2018年1月10日

分苹果(网易)

摘要: 题目描述 n 只奶牛坐在一排,每个奶牛拥有 ai 个苹果,现在你要在它们之间转移苹果,使得最后所有奶牛拥有的苹果数都相同,每一次,你只能从一只奶牛身上拿走恰好两个苹果到另一个奶牛上,问最少需要移动多少次可以平分苹果,如果方案不存在输出 -1。 输入描述: 每个输入包含一个测试用例。每个测试用例的第一 阅读全文

posted @ 2018-01-10 19:52 夜的第八章 阅读(164) 评论(0) 推荐(0) 编辑

Flatten Binary Tree to Linked List

摘要: Given a binary tree, flatten it to a linked list in-place. For example,Given The flattened tree should look like: Hints: If you notice carefully in th 阅读全文

posted @ 2018-01-10 17:13 夜的第八章 阅读(102) 评论(0) 推荐(0) 编辑

Construct Binary Tree from Inorder and Postorder Traversal(根据中序遍历和后序遍历构建二叉树)

摘要: 根据中序和后续遍历构建二叉树。 阅读全文

posted @ 2018-01-10 15:28 夜的第八章 阅读(96) 评论(0) 推荐(0) 编辑

Construct Binary Tree from Preorder and Inorder Traversal(根据前序中序构建二叉树)

摘要: 根据前序中序构建二叉树。 参考:https://www.cnblogs.com/springfor/p/3884034.html 阅读全文

posted @ 2018-01-10 12:12 夜的第八章 阅读(127) 评论(3) 推荐(0) 编辑

Validate Binary Search Tree(一定掌握的方法)

摘要: Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only 阅读全文

posted @ 2018-01-10 10:53 夜的第八章 阅读(146) 评论(0) 推荐(0) 编辑

导航