Skip to content

feat(data_structures): add sliding window maximum using monotonic deque (#3225) - #3255

Open
akhila-pynam wants to merge 1 commit into
TheAlgorithms:masterfrom
akhila-pynam:feat/sliding-window-maximum
Open

akhila-pynam wants to merge 1 commit into
TheAlgorithms:masterfrom
akhila-pynam:feat/sliding-window-maximum

Conversation

@akhila-pynam

Copy link
Copy Markdown

Summary of Changes

  • Implements the Sliding Window Maximum algorithm using a monotonic double-ended queue (std::deque) in data_structures/sliding_window_maximum.cpp.
  • Time Complexity: $\mathcal{O}(N)$ as each element index is pushed and popped from the deque at most once.
  • Auxiliary Space Complexity: $\mathcal{O}(k)$ for storing up to $k$ indices.
  • Supports generic numeric types (template <typename T>) with handling for edge cases (empty, k == 0, k >= N).
  • Includes a comprehensive self-test suite using assert().
  • Formatted with clang-format and complies with clang-tidy rules.

Fixes #3225

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

[FEATURE]Add Sliding Window Maximum algorithm using Deque

1 participant