Help needed in a problem

Revision en1, by NoobCoder1998, 2023-09-30 06:42:20

Given an array nums containing N distinct integers and an integer K. You can perform any number of operations:

Select a sub-array of length K in nums and replace all the elements in the sub- array with the maximum number present in the current sub-array.

Find the minimum number of operations such that nums[1]=nums[n].

Input Format

The first line contains an integer N, where N denotes the number of elements in the array in the array. The second line contains N space- separated integers. The third line contains an integer, K.

Output Format

Print the minimum number of operations such that nums[1] nums[n].


•2sN,Ks10^5 • 1s am[i] $10^9

-I tried solving it but not able to find any optimal approach for the same.


  Rev. Lang. By When Δ Comment
en1 English NoobCoder1998 2023-09-30 06:42:20 785 Initial revision (published)