Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Day 17 #17

Open
shivvamm opened this issue Sep 15, 2023 · 0 comments
Open

Day 17 #17

shivvamm opened this issue Sep 15, 2023 · 0 comments

Comments

@shivvamm
Copy link
Owner

shivvamm commented Sep 15, 2023

Given an array of integers and a number k, where 1 <= k <= length of the array, compute the maximum values of each subarray of length k.

For example, given array = [10, 5, 2, 7, 8, 7] and k = 3, we should get:[10, 7, 8, 8], since:

7 = max(5, 2, 7)
8 = max(2, 7, 8)
8 = max(7, 8, 7)

Do this inO(n)time andO(k)space. You can modify the input array in-place and you do not need to store the results. You can simply print them out as you compute them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant