Skip to main content

Longest Increasing Subsequence

https://img.shields.io/pypi/v/longest_increasing_subsequence.svg https://travis-ci.com/mCodingLLC/longest_increasing_subsequence.svg?branch=master Documentation Status

Find the longest increasing or decreasing subsequence of a sequence.

Install with:

pip install longest-increasing-subsequence

Usage:

from longest_increasing_subsequence import (longest_increasing_subsequence,
                                            longest_decreasing_subsequence,
                                            longest_increasing_subsequence_indices)

longest_increasing_subsequence([0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15])
# [0, 2, 6, 9, 11, 15]

longest_increasing_subsequence([0, 0, 1, 2, 3, 2, 1, 0, 0])
# [0, 0, 1, 2, 2]

longest_decreasing_subsequence([0, 0, 1, 2, 3, 2, 1, 0, 0])
# [3, 2, 1, 0, 0]

longest_increasing_subsequence([0, 0, 1, 2, 3], strict=True)
# [0, 1, 2, 3]

longest_increasing_subsequence(['A', 'B', 'CC', 'D', 'EEE'], key=len)
# ['A', 'B', 'D', 'EEE']

"".join(longest_increasing_subsequence('aababbbdccddd'))
# 'aaabbbccddd'

longest_increasing_subsequence_indices([0, 0, 1, 2, 3, 2, 1, 0, 0])
# [0, 1, 2, 3, 5]

Features

  • Works with arbitrary sequence types (list, tuple, str, numpy array, pandas series, etc.)

  • Works with arbitrary comparable elements (anything that has < and >).

  • Can compute increasing or decreasing subsequences.

  • Can compute strictly increasing or strictly decreasing subsequences.

  • Can compare elements by an optional key function (e.g. compare strings by length).

  • Can return the subsequence or the indices of the subsequence.

Credits

This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.

History

0.1.0 (2021-02-15)

  • First release on PyPI.

Metadata

Release files for longest-increasing-subsequence 0.1.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for longest-increasing-subsequence 0.1.7
File Size Uploaded Provenance Actions
longest_increasing_subsequence-0.1.7.tar.gz 12.7 kB Without provenance Details for longest_increasing_subsequence-0.1.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for longest-increasing-subsequence 0.1.7
File Interpreter ABI Platform Actions
longest_increasing_subsequence-0.1.7-py2.py3-none-any.whl Python 2, Python 3 none any Details for longest_increasing_subsequence-0.1.7-py2.py3-none-any.whl

Total release size: 18.9 kB

Release files / longest_increasing_subsequence-0.1.7.tar.gz

Download URL longest_increasing_subsequence-0.1.7.tar.gz
Size 12.7 kB
Tags Source
SHA-256 checksum
How to use checksums
ad94a6449c58b97831472a7e33d35e4574f6fd3da28c1f495f16bfecec9a914c
BLAKE2b-256 checksum
How to use checksums
255a19b92abaaae74669272db2aef14d19c14edd9e1bea8f16fcfaa53ca41d10
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1

Release files / longest_increasing_subsequence-0.1.7-py2.py3-none-any.whl

Download URL longest_increasing_subsequence-0.1.7-py2.py3-none-any.whl
Size 6.2 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
0b31169d142011307894c21faba13315ec8922f84c1b273f53d3e36fca52484e
BLAKE2b-256 checksum
How to use checksums
ad5a983681b60cdbb4f8b2ea2f25a6a2e7b3d79f55366cbd4f05b3dca54fa320
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/53.0.0 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1

Security for longest-increasing-subsequence 0.1.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page