Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Minimum number of student remaining

Правка en1, от gaand_na_phulao, 2020-06-15 18:49:11

Yesterday I had a Samsung test. I wasn't able to solve it. The question was like this

You have given n student with their id. Students are standing in a queue. You have also an integer k. You can remove the students such that their id follows this rule: - arr[i-1]+k=arr[i]=arr[i+1]-k .(All three students will be removed from the queue). You have to remove these students such that the minimum number of student will be remaining at the end.

Constraints: 1<=t<=20 3<=n<=100. 1<=arr[i]<=10^6. 1<=k<=10^6.

Input : 2 6 1 3 4 5 6 7 5 5 1 1 2 3 4 5

Output: 0 2

Explanation: In the first test case, If we remove 5 6 7 then the remaining array will be 3 4 5. Now again I can remove these students. So the minimum number of student remaining will be 0.

In second test case, we can remove more than three students from the queue. So the remaining number of students will be 2.

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en19 Английский gaand_na_phulao 2020-06-15 19:13:18 0 (published)
en18 Английский gaand_na_phulao 2020-06-15 19:12:56 14 (saved to drafts)
en17 Английский gaand_na_phulao 2020-06-15 19:10:37 1 Tiny change: 'nts follows this rule' -> 'nts follow this rule' (published)
en16 Английский gaand_na_phulao 2020-06-15 19:09:52 26 (saved to drafts)
en15 Английский gaand_na_phulao 2020-06-15 19:07:26 0 (published)
en14 Английский gaand_na_phulao 2020-06-15 19:06:58 54 (saved to drafts)
en13 Английский gaand_na_phulao 2020-06-15 19:05:12 0 (published)
en12 Английский gaand_na_phulao 2020-06-15 19:03:52 0 Tiny change: ' queue).\n\nYou ha' -> ' queue).\n- You can\n\nYou ha'
en11 Английский gaand_na_phulao 2020-06-15 19:02:55 3
en10 Английский gaand_na_phulao 2020-06-15 19:02:26 8
en9 Английский gaand_na_phulao 2020-06-15 19:01:45 8
en8 Английский gaand_na_phulao 2020-06-15 19:00:59 2 Tiny change: 'se, we can remove mo' -> 'se, we can't remove mo'
en7 Английский gaand_na_phulao 2020-06-15 18:58:59 7
en6 Английский gaand_na_phulao 2020-06-15 18:57:23 115
en5 Английский gaand_na_phulao 2020-06-15 18:53:48 10
en4 Английский gaand_na_phulao 2020-06-15 18:52:51 14
en3 Английский gaand_na_phulao 2020-06-15 18:52:07 29
en2 Английский gaand_na_phulao 2020-06-15 18:51:06 32
en1 Английский gaand_na_phulao 2020-06-15 18:49:11 944 Initial revision (saved to drafts)