Name | monotonic-stack JSON |
Version | 0.1.1 JSON |
download | |
home_page | |
Summary | A monotonic stack |
upload_time | 2023-11-28 22:08:01 |
maintainer | |
docs_url | None |
author | |
requires_python | |
license | |
keywords | monotonic stack |
VCS | |
bugtrack_url | |
requirements | No requirements were recorded. |
Travis-CI | No Travis. |
coveralls test coverage | No coveralls. |
# Monotonic Stack The monotonic increasing stack and monotonic decreasing stack, namely monotonic stack, is a very powerful tool for finding next greater/smaller element. More specifically, always **use monotonic increasing stack when we are trying to find the next smaller element, vice versa.** The typical usage of monotonic stack is to find the next greater/smaller element in an array. ``` pip install monotonic_stack ``` This monotonic stack: - works with any Python sequence, not just strings, if the items are hashable - is implemented in pure Python PyPi: https://pypi.org/project/monotonic-stack/ ## Usage ``` py >>> from monotonic_stack import MonotonicStack >>> MS = MonotonicStack([1, 2, 3, 4, 5]) >>> MS.next_greater_on_right() [2, 3, 4, 5, -1] >>> MS.next_greater_on_left() [-1, 1, 2, 3, 4] >>> MS.next_smaller_on_right() [-1, -1, -1, -1, -1] >>> MS.next_smaller_on_left() [-1, -1, -1, -1, -1] ```
{ "_id": null, "home_page": "", "name": "monotonic-stack", "maintainer": "", "docs_url": null, "requires_python": "", "maintainer_email": "", "keywords": "monotonic,stack", "author": "", "author_email": "Zhengyuan Zhu <zhuzhengyuan824@gmail.com>", "download_url": "https://files.pythonhosted.org/packages/6f/20/04eb1db1f9ac0d2db1984f8e04da80dbb20b63d3b05867a183ecc540cb18/monotonic_stack-0.1.1.tar.gz", "platform": null, "description": "# Monotonic Stack\n\nThe monotonic increasing stack and monotonic decreasing stack, namely monotonic stack, is a very powerful tool for finding next greater/smaller element.\nMore specifically, always **use monotonic increasing stack when we are trying to find the next smaller element, vice versa.**\nThe typical usage of monotonic stack is to find the next greater/smaller element in an array.\n\n```\npip install monotonic_stack\n```\n\n\nThis monotonic stack:\n- works with any Python sequence, not just strings, if the items are hashable\n- is implemented in pure Python\n\nPyPi: https://pypi.org/project/monotonic-stack/\n\n## Usage\n\n``` py\n>>> from monotonic_stack import MonotonicStack\n>>> MS = MonotonicStack([1, 2, 3, 4, 5])\n>>> MS.next_greater_on_right()\n[2, 3, 4, 5, -1]\n>>> MS.next_greater_on_left()\n[-1, 1, 2, 3, 4]\n>>> MS.next_smaller_on_right()\n[-1, -1, -1, -1, -1]\n>>> MS.next_smaller_on_left()\n[-1, -1, -1, -1, -1]\n```\n", "bugtrack_url": null, "license": "", "summary": "A monotonic stack", "version": "0.1.1", "project_urls": { "Homepage": "https://github.com/824zzy/monotonic_stack" }, "split_keywords": [ "monotonic", "stack" ], "urls": [ { "comment_text": "", "digests": { "blake2b_256": "7d3f477e4cafed899a0becfbcf0abac624203875a0c290e28b13e7bd7af09500", "md5": "332fb2b3f67dbfba1dcb3de0c8d671d2", "sha256": "070bfddc387e9ec1615962d2ee745d1aa09f82af63285db13eb9f8be608d8715" }, "downloads": -1, "filename": "monotonic_stack-0.1.1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "332fb2b3f67dbfba1dcb3de0c8d671d2", "packagetype": "bdist_wheel", "python_version": "py2.py3", "requires_python": null, "size": 2869, "upload_time": "2023-11-28T22:07:59", "upload_time_iso_8601": "2023-11-28T22:07:59.257628Z", "url": "https://files.pythonhosted.org/packages/7d/3f/477e4cafed899a0becfbcf0abac624203875a0c290e28b13e7bd7af09500/monotonic_stack-0.1.1-py2.py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "blake2b_256": "6f2004eb1db1f9ac0d2db1984f8e04da80dbb20b63d3b05867a183ecc540cb18", "md5": "ec28ae40bb9d99f099b53dafe4043bd6", "sha256": "7ed50748855f539de73f884391f678832cb9b20a7a36e231e82c0bc9b4da1075" }, "downloads": -1, "filename": "monotonic_stack-0.1.1.tar.gz", "has_sig": false, "md5_digest": "ec28ae40bb9d99f099b53dafe4043bd6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2212, "upload_time": "2023-11-28T22:08:01", "upload_time_iso_8601": "2023-11-28T22:08:01.123841Z", "url": "https://files.pythonhosted.org/packages/6f/20/04eb1db1f9ac0d2db1984f8e04da80dbb20b63d3b05867a183ecc540cb18/monotonic_stack-0.1.1.tar.gz", "yanked": false, "yanked_reason": null } ], "upload_time": "2023-11-28 22:08:01", "github": true, "gitlab": false, "bitbucket": false, "codeberg": false, "github_user": "824zzy", "github_project": "monotonic_stack", "travis_ci": false, "coveralls": false, "github_actions": false, "lcname": "monotonic-stack" }