这道题首先要明确题目背景 二叉搜索树。也正是因为是二叉搜索树,所以我们可以利用二叉搜索树从小到大排好序的特性来做。 对于一个root和另外两个Node来说,它们的值会有以下几种情况: 1. root.val < p.val && root.val < q.val 此时,两个node的值都比root大 ...
分类:
其他好文 时间:
2018-03-03 12:29:41
阅读次数:
188
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes ...
分类:
其他好文 时间:
2018-03-03 12:14:41
阅读次数:
117
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia ...
分类:
其他好文 时间:
2018-03-03 11:02:54
阅读次数:
143
题目: Given two strings s1, s2, find the lowest ASCII sum of deleted characters to make two strings equal. Example 1: Example 2: Note: 0 < s1.length, s2 ...
分类:
其他好文 时间:
2018-02-15 14:16:38
阅读次数:
142
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes ...
分类:
其他好文 时间:
2018-02-11 23:38:31
阅读次数:
208
Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST. According to the definition of LCA on Wikipedia ...
分类:
其他好文 时间:
2018-02-11 18:09:15
阅读次数:
143
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According to the definition of LCA on Wikipedia: “The lowes ...
分类:
其他好文 时间:
2018-02-05 23:16:33
阅读次数:
157
A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer ...
分类:
其他好文 时间:
2018-02-05 21:38:15
阅读次数:
190
Given a non-empty list of words, return the k most frequent elements. Your answer should be sorted by frequency from highest to lowest. If two words h ...
分类:
其他好文 时间:
2018-02-04 14:40:15
阅读次数:
284