_aditya's blog

By _aditya, history, 5 years ago, In English

Lets say we have a running stream of numbers. We have to insert each element to a sorted list, before inserting we have to find the position of element in list. The only way I know to do it efficiently is augmenting a AVL tree. And also there are policy based data structures. do you know some algorithm that can do this in logn?

Full text and comments »

  • Vote: I like it
  • +5
  • Vote: I do not like it

By _aditya, history, 5 years ago, In English

There is a list of key vs value pair.size = n. No I have been given a key I have to find the max value from the list such that its key is less than the given key.

If there are q queries I can do this in O(qn). Is there a faster way to do this.

Full text and comments »

  • Vote: I like it
  • -4
  • Vote: I do not like it

By _aditya, history, 6 years ago, In English

there are 'n' nodes and 'm' edges in a graph. each node may or may not contain certain number of a item. all nodes have same item but different number of that item.

we have to go from source to destination in minimum time collecting 'k' number of this item. each edge is weighted,weights may or may not be same. there are no self loops. edges are bidirectional.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By _aditya, history, 6 years ago, In English

i encountered this problem on a hiring contest and dont think its editorial will be provided. It goes like there's an array of n numbers and a number k is given. both n,k<=10^5 arr[i]<=10^5 we have to find minimum number of swaps so that all numbers greater than k are clubber together.

Full text and comments »

  • Vote: I like it
  • +2
  • Vote: I do not like it