Maximum in Subarrays of length K
Posted: 28 Jul, 2020
Given an array of integers of size N and a number K, print the maximum value of each subarray of length K in the array
The first line contains two single space separated integers, N and K. The second line contains N single space separated integers denoting the elements of the array.
A single line consisting of N - K + 1 single space separated integers denoting the maximum values of the K-sized subarrays where the subarrays are taken in a left to right fashion starting from the 0th index.
0 <= N <= 5 * (10 ^ 5) 1 <= K <= N Time Limit: 1 sec
- Create a nested loop. The outer loop will go from i = 0 to i = ‘N’ - ‘K’. This will cover the starting indices of all K-subarrays
- The inner loop will go from j = i to j = i + K - 1. This will cover all the elements of the K-subarray starting from index i
- Keep track of the maximum element in the inner loop and print it.
Game of 3
Posted: 11 Jul, 2021
Lexicographic Permutation Rank
Posted: 13 Jul, 2021
Zero Pair Sum
Posted: 22 Jul, 2021
Implement a Queue
Posted: 27 Jul, 2021
Remove K Corner Elements
Posted: 31 Jul, 2021