随笔分类 -  leetcode

Palindrome Partitioning
摘要:Given a string s, partition s such that every substring of the partition is a palindrome. Return all possible palindrome partitioning of s. For exampl 阅读全文

posted @ 2018-01-11 16:18 夜的第八章 阅读(108) 评论(0) 推荐(0)

triangle
摘要:Given a triangle, find the minimum path sum from top to bottom. Each step you may move to adjacent numbers on the row below. For example, given the fo 阅读全文

posted @ 2018-01-11 14:58 夜的第八章 阅读(151) 评论(0) 推荐(0)

Populating Next Right Pointers in Each Node(I and II)
摘要:Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to point to its ne 阅读全文

posted @ 2018-01-11 10:10 夜的第八章 阅读(100) 评论(0) 推荐(0)

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

posted @ 2018-01-10 19:52 夜的第八章 阅读(179) 评论(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 夜的第八章 阅读(107) 评论(0) 推荐(0)

Construct Binary Tree from Inorder and Postorder Traversal(根据中序遍历和后序遍历构建二叉树)
摘要:根据中序和后续遍历构建二叉树。 阅读全文

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

Construct Binary Tree from Preorder and Inorder Traversal(根据前序中序构建二叉树)
摘要:根据前序中序构建二叉树。 参考:https://www.cnblogs.com/springfor/p/3884034.html 阅读全文

posted @ 2018-01-10 12:12 夜的第八章 阅读(137) 评论(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 夜的第八章 阅读(152) 评论(0) 推荐(0)

path sum II(深度优先的递归实现掌握)
摘要:Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum. For example:Given the below binary tree and sum 阅读全文

posted @ 2018-01-09 20:34 夜的第八章 阅读(142) 评论(0) 推荐(0)

convert sorted list to binary search tree(将有序链表转成平衡二叉搜索树)
摘要:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced bina 阅读全文

posted @ 2018-01-09 19:26 夜的第八章 阅读(211) 评论(0) 推荐(0)

Binary Tree Zigzag Level Order Traversal(z字形打印二叉树)
摘要:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and 阅读全文

posted @ 2018-01-09 11:25 夜的第八章 阅读(238) 评论(0) 推荐(0)

unique-binary-search-trees II
摘要:Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n. For example,Given n = 3, your program should 阅读全文

posted @ 2018-01-08 16:42 夜的第八章 阅读(129) 评论(0) 推荐(0)

unique-binary-search-trees
摘要:unique-binary-search-trees 题目: Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For example,Given n = 3, the 阅读全文

posted @ 2018-01-08 15:42 夜的第八章 阅读(233) 评论(0) 推荐(0)

reverse Linked List II
摘要:Reverse a linked list from position m to n. Do it in-place and in one-pass. For example:Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2- 阅读全文

posted @ 2018-01-08 11:00 夜的第八章 阅读(219) 评论(0) 推荐(0)

decode ways(动态规划)
摘要:A message containing letters from A-Z is being encoded to numbers using the following mapping: Given an encoded message containing digits, determine t 阅读全文

posted @ 2018-01-07 17:48 夜的第八章 阅读(131) 评论(0) 推荐(0)

word search(二维数组中查找单词(匹配字符串))
摘要:Given a 2D board and a word, find if the word exists in the grid. The word can be constructed from letters of sequentially adjacent cell, where "adjac 阅读全文

posted @ 2018-01-07 15:07 夜的第八章 阅读(4417) 评论(0) 推荐(0)

Remove Duplicates from Sorted List II
摘要:Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example,Given 1->2 阅读全文

posted @ 2018-01-06 15:57 夜的第八章 阅读(136) 评论(0) 推荐(0)

partition List(划分链表)
摘要:Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should preserve the 阅读全文

posted @ 2018-01-06 14:50 夜的第八章 阅读(342) 评论(0) 推荐(0)

search in rotated sorted array II
摘要:Follow up for "Search in Rotated Sorted Array":What if duplicates are allowed? Would this affect the run-time complexity? How and why? Suppose an arra 阅读全文

posted @ 2018-01-06 14:20 夜的第八章 阅读(186) 评论(0) 推荐(0)

search a 2D matrix(在二维数组中搜索一个元素)
摘要:Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: Integers in each row are sorted f 阅读全文

posted @ 2018-01-06 10:55 夜的第八章 阅读(155) 评论(0) 推荐(0)

导航