[CareerCup][Google Interview] Find kth number in a BST - chkkch - 博客园
Given n elements, sort the elements. Here, only one operation is permitted decreaseValue..Note that you cannot swap the values.. output should be a sorted list..
if input is 4 5 2 1 3
output is 3 3 3.. There can be many answers.. Give the optimum solution with minimum cost. where as cost is the sum of decreased amounts..
for this example, 4,5 are decreased by 1.. 2 is decreased by 2.. 1 is decreased by 1..
Read full article from [CareerCup][Google Interview] Find kth number in a BST - chkkch - 博客园
No comments:
Post a Comment