摘要:题目描述 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 阅读全文
posted @ 2019-10-09 18:59 schaffen 阅读 (2) 评论 (0) 编辑
摘要:题目描述 Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST. Calling next() will return 阅读全文
posted @ 2019-10-09 18:57 schaffen 阅读 (3) 评论 (0) 编辑
摘要:题目描述 Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: Example 2: 参考答案 答案分析 分成三部分: 1. 链接首尾 2. 移动 3. 拆 阅读全文
posted @ 2019-10-08 20:23 schaffen 阅读 (7) 评论 (0) 编辑
摘要:题目描述 Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists. Exa 阅读全文
posted @ 2019-10-07 17:34 schaffen 阅读 (6) 评论 (0) 编辑
摘要:题目描述 Reverse a singly linked list. Example: 参考答案 补充说明 term 1: temp = 2 3 4 5 null head = 1 null = 1 2 3 4 5 null + null cur = 1 null head = 2 3 4 5 nu 阅读全文
posted @ 2019-10-06 11:54 schaffen 阅读 (6) 评论 (0) 编辑
摘要:题目描述 Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To represent a cycle in the given linked list, we 阅读全文
posted @ 2019-10-05 19:40 schaffen 阅读 (6) 评论 (0) 编辑
摘要:题目描述 Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The an 阅读全文
posted @ 2019-10-03 17:02 schaffen 阅读 (5) 评论 (0) 编辑
摘要:题目描述 144. Binary Tree Preorder Traversal 94. Binary Tree Inorder Traversal 145. Binary Tree Postorder Traversal 前序排列 :根-左-右 中序排列: 左-根-右 后序排列:左-右-根 参考答 阅读全文
posted @ 2019-10-02 23:28 schaffen 阅读 (8) 评论 (0) 编辑
摘要:题目描述 Given a string, find the first non-repeating character in it and return it's index. If it doesn't exist, return -1. Examples: Note: You may assum 阅读全文
posted @ 2019-10-02 01:11 schaffen 阅读 (9) 评论 (0) 编辑
摘要:题目描述 Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite restaurants represented by strings. You need 阅读全文
posted @ 2019-09-30 22:12 schaffen 阅读 (5) 评论 (0) 编辑