Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. 找二叉搜索树中第k个小的值。 用中序遍历,增加一个全局变量记录访问到第几个节点,返回访问的第k个节点的值。 ...
分类:
其他好文 时间:
2017-12-20 03:51:14
阅读次数:
132
一个BST, 问怎么找到第二大的节点。首先说了个naive的方法,serialize, 他问有没有更有效的方法。最后用的iterative的方法向右遍历子节点 log(n) 或者inorder, O(n): 230. Kth Smallest Element in a BST ...
分类:
其他好文 时间:
2017-12-14 03:46:57
阅读次数:
113
This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students. Inp ...
分类:
其他好文 时间:
2017-12-12 23:56:39
阅读次数:
310
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
not one pass: 1)Take 2 pointer move one pointer by 5 position ie, the difference between the two pointer is 5. 2)Now traverse through the list till th ...
分类:
其他好文 时间:
2017-12-10 11:15:15
阅读次数:
186
In this lesson, you will learn what mutable and immutable objects are, and the difference between them. This understanding will help you determine whe ...
分类:
编程语言 时间:
2017-12-09 19:32:54
阅读次数:
134
page3.Overview of Blocking vs Non-Blocking This overview covers the difference between blocking and non-blocking calls in Node.js. This overview will ...
分类:
Web程序 时间:
2017-12-08 23:57:18
阅读次数:
276