一个BST, 问怎么找到第二大的节点。首先说了个naive的方法,serialize, 他问有没有更有效的方法。最后用的iterative的方法向右遍历子节点 log(n) 或者inorder, O(n): 230. Kth Smallest Element in a BST ...
分类:
其他好文 时间:
2017-12-14 03:46:57
阅读次数:
113
Given a list of sorted characters letters containing only lowercase letters, and given a target letter target, find the smallest element in the list t ...
分类:
其他好文 时间:
2017-12-12 15:16:44
阅读次数:
152
Given a list of sorted characters letters containing only lowercase letters, and given a target letter target, find the smallest element in the list t... ...
分类:
其他好文 时间:
2017-12-12 00:20:22
阅读次数:
190
"计算数组中最小的两个数的和" #!usr/bin/python3 #-*- coding:utf-8 -*- numbers=np.array((4,3,7,5,6)) def sum_two_smallest_numbers(numbers): numbers.sort() return num... ...
分类:
编程语言 时间:
2017-12-11 16:14:42
阅读次数:
123
题目描述: LeetCode 483. Smallest Good Base For an integer n, we call k>=2 a good base of n, if all digits of n base k are 1. Now given a string representi ...
分类:
其他好文 时间:
2017-12-03 17:17:25
阅读次数:
365
Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. Note: You may assume k is always valid, 1 ≤ k ≤ BST's ...
分类:
其他好文 时间:
2017-12-03 11:41:35
阅读次数:
159
题目: An ascending sorted sequence of distinct values is one in which some form of a less-than operator is used to order the elements from smallest to l ...
分类:
编程语言 时间:
2017-12-02 16:22:40
阅读次数:
157
An image is represented by a binary matrix with 0 as a white pixel and 1 as a black pixel. The black pixels are connected, i.e., there is only one bla ...
分类:
其他好文 时间:
2017-11-26 16:00:31
阅读次数:
172