Skip to content

Instantly share code, notes, and snippets.

@Raghavagr
Created April 12, 2022 18:46

SAMPLE INPUT - 1

arr = [12, -1, -7, 8, -15, 30, 18, 28]

k = 3

SAMPLE OUTPUT - 1

[-1, -1, -7, -15, -15, 0]

EXPLANATION

All window of K size will be,

  • [12, -1, -7] = First negative is -1
  • [-1, -7, 8] = -1
  • [-7, 8, -15] = -7
  • [8, -15, 30] = -15
  • [-15, 30, 18] = -15
  • [30, 18, 28] = 0

Hence the final result will be [-1, -1, -7, -15, -15, 0]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment