{"id":18016944,"url":"https://github.com/fitzgen/longest-increasing-subsequence","last_synced_at":"2025-08-02T21:35:04.332Z","repository":{"id":48425301,"uuid":"179374673","full_name":"fitzgen/longest-increasing-subsequence","owner":"fitzgen","description":"A crate for finding a longest increasing subsequence of some input","archived":false,"fork":false,"pushed_at":"2023-05-29T02:57:37.000Z","size":22,"stargazers_count":9,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-07-30T01:37:20.836Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://docs.rs/longest-increasing-subsequence/","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fitzgen.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-04-03T21:42:43.000Z","updated_at":"2025-04-02T11:00:22.000Z","dependencies_parsed_at":"2024-10-30T04:54:10.854Z","dependency_job_id":null,"html_url":"https://github.com/fitzgen/longest-increasing-subsequence","commit_stats":{"total_commits":14,"total_committers":2,"mean_commits":7.0,"dds":0.2857142857142857,"last_synced_commit":"9fb5badb975a423644fcf084f3e57cb30eb3aa08"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/fitzgen/longest-increasing-subsequence","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Flongest-increasing-subsequence","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Flongest-increasing-subsequence/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Flongest-increasing-subsequence/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Flongest-increasing-subsequence/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fitzgen","download_url":"https://codeload.github.com/fitzgen/longest-increasing-subsequence/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fitzgen%2Flongest-increasing-subsequence/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268457078,"owners_count":24253348,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-30T04:19:44.386Z","updated_at":"2025-08-02T21:35:04.268Z","avatar_url":"https://github.com/fitzgen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `longest-increasing-subsequence`\n\n\n[![](https://docs.rs/longest-increasing-subsequence/badge.svg)](https://docs.rs/longest-increasing-subsequence/)\n[![](https://img.shields.io/crates/v/longest-increasing-subsequence.svg)](https://crates.io/crates/longest-increasing-subsequence)\n[![](https://img.shields.io/crates/d/longest-increasing-subsequence.svg)](https://crates.io/crates/longest-increasing-subsequence)\n[![Build Status](https://dev.azure.com/fitzgen/longest-increasing-subsequence/_apis/build/status/fitzgen.longest-increasing-subsequence?branchName=master)](https://dev.azure.com/fitzgen/longest-increasing-subsequence/_build/latest?definitionId=1\u0026branchName=master)\n\n### Longest Increasing Subsequence\n\n\u003e The longest increasing subsequence problem is to find a subsequence of a given\n\u003e sequence in which the subsequence's elements are in sorted order, lowest to\n\u003e highest, and in which the subsequence is as long as possible. This subsequence\n\u003e is not necessarily contiguous, or unique.\n\n\u0026mdash; [Wikipedia](https://en.wikipedia.org/wiki/Longest_increasing_subsequence)\n\nFor example, consider this sequence of integers:\n\n\u003e 2, 9, 4, 7, 3, 4, 5\n\nThe longest increasing subsequence (LIS) for this sequence is *2, 3, 4, 5*.\n\nNote that there is not always a *singular* LIS. Consider this sequence:\n\n\u003e 2, 6, 5\n\nIn this sequence, both *2, 5* and *2, 6* are LISs.\n\n### API\n\nThis crate exposes two functions for finding a longest increasing subsequence\nwithin a slice:\n\n1. The high-level, easy-to-use `lis` function takes any slice of `T: Ord` and\nreturns the LIS as a vector of indices into that slice.\n\n2. The low-level `lis_with` function takes a custom comparator and lets you\nbring your own allocations (which lets you choose to reuse allocations or use a\ncustom allocator).\n\nBoth functions use the same underlying algorithm. They execute in *O(n log n)*\ntime and use *O(n)* memory.\n\n### Example\n\n```rust\nuse longest_increasing_subsequence::lis;\n\nlet xs = vec![9, 2, 8, 3, 5];\nfor i in lis(\u0026xs) {\n    println!(\"{} at index {}\", xs[i], i);\n}\n\n// Prints:\n// 2 at index 1\n// 3 at index 3\n// 5 at index 4\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitzgen%2Flongest-increasing-subsequence","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffitzgen%2Flongest-increasing-subsequence","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffitzgen%2Flongest-increasing-subsequence/lists"}