Блог пользователя sntmessages

Автор sntmessages, 10 лет назад, По-английски

Hi, I have just managed to find sorted subsequence of length 3 in an unsorted array.
I want to know how to do it to find subsequence of length k.

length of an array can be upto 100000.

Actual Question is : Given an unsorted array of n integers, find the 3 elements such that a[x] < a[y] < a[z] and x < y < z. I have done it in O(n) space and time complexity.
But I want to do it for k elements.

Полный текст и комментарии »

  • Проголосовать: нравится
  • -6
  • Проголосовать: не нравится

Автор sntmessages, 12 лет назад, По-английски

i have some doubt about this problem. it is written in the problem statement that "Vova needs the pipeline to have exactly n pipes with flowing out water."

considering this statement the answer for test case : 21 8 is '-1' . since for k=8 number of pipes can be 1,8,14,19,23,26,28,29 and it is written that pipeline should have exactly n pipes with flowing out water, therefore, 21 cant be possible.

i have run custom test and it is showing me o/p as '4'. am i missing something? please help.

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится