Giter Club home page Giter Club logo

liseq's Introduction

Longest increasing sub-sequence

The longest increasing sub-sequence is a more general sub-set of a sequence than the longest increasing substring that you are already familiar with.

We can think of sub-sequences of a sequence x as an increasing list of indices is where is is increasing and so is [x[i] for i in is]. A sub-string is one where the indices in is are consequtive, i.e. is = [k, k+1, k+2, ...] for some k. A general sub-sequence doesn't have to obey that rule.

A very simple (and very inefficient) way to find the longest common sub-sequence is to generate every possible sub-sequence, i.e. every possible list is of increasing indices into x, check if [x[i] for i in is] is increasing, and then pick the longest of these. (We don't care how you resolve conflicts this time.)

Can you work out how to do this? Then go to src/liseq.py and try it out.

If you made it this far, you are done with all the other exercises for the week, so I'll give you one extra task. Try to write tests for your function. I have left a function for it in src/test_liseq.py.

liseq's People

Contributors

mailund avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.