feat: add kth next greater element script to /data_structures/stacks/.#14728
feat: add kth next greater element script to /data_structures/stacks/.#14728StarsExpress wants to merge 6 commits into
Conversation
There was a problem hiding this comment.
Click here to look at the relevant links ⬇️
🔗 Relevant Links
Repository:
Python:
Automated review generated by algorithms-keeper. If there's any problem regarding this review, please open an issue about it.
algorithms-keeper commands and options
algorithms-keeper actions can be triggered by commenting on this PR:
@algorithms-keeper reviewto trigger the checks for only added pull request files@algorithms-keeper review-allto trigger the checks for all the pull request files, including the modified files. As we cannot post review comments on lines not part of the diff, this command will post all the messages in one comment.NOTE: Commands are in beta and so this feature is restricted only to a member or owner of the organization.
|
@poyea |
|
I submitted this pull request about two weeks ago. Could you please have a look? Feel free to ask me anything 🙏 |
There was a problem hiding this comment.
Pull request overview
Adds a new stack-based algorithm implementation to compute the k-th Next Greater Element (NGE) for every element in an input array, generalizing the existing 1st-NGE approach.
Changes:
- Introduces
find_kth_next_greater_element()using k monotonic stacks to compute k-th NGE results. - Adds doctest examples and a
__main__block for local doctest execution + simple timing.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@poyea |
Describe your change:
Add kth Next Greatest Element (NGE) algorithm using k monotonic decreasing stacks.
It generalizes the existing first NGE to an arbitrary k, running in O(kn) average time with O(n) space.
Checklist: