Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6754923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:20:19+00:00 2026-05-26T13:20:19+00:00

How to find the longest continuous number sequence in array of number arrays? Each

  • 0

How to find the longest continuous number sequence in array of number arrays? Each array of numbers represent one or zero numbers in resulting sequence.

Example ([] – represents array (like in javascript)):

[
    [1, 5, 6],
    [7],
    [22, 34],
    [500, 550],
    [60, 1],
    [90, 100],
    [243],
    [250, 110],
    [150],
    [155],
    [160]
]

Correct output would be: [1, 7, 22, 60, 90, 110, 150, 155, 160]

Detailed output:

1,   -- index  1 all 1, 5 and 6 would match here, pick the smallest
7,   -- index  2
22,  -- index  3
     -- index  4 skipped, the sequence would end here or wouldn't be the longest possible
60,  -- index  5 picked 60, because 1 wouldn't continue in the sequence
90,  -- index  6
     -- index  7 skipped, the sequence would end here or wouldn't be the longest possible
110, -- index  8
150, -- index  9
155, -- index 10
160  -- index 11
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:20:20+00:00Added an answer on May 26, 2026 at 1:20 pm

    A possible approach is to use dynamic programming using as parameters the last value and the index of first sub-array to consider.

    This is a solution in Python based on recursion with memoization

    data = [[1, 5, 6],
            [7],
            [22, 34],
            [500, 550],
            [60, 1],
            [90, 100],
            [243],
            [250, 110],
            [150],
            [155],
            [160]]
    
    def longest(x0, i, _cache=dict()):
        if i == len(data):
            return []
        try:
            return _cache[x0, i]
        except KeyError:
            best = longest(x0, i+1)
            for x in data[i]:
                if x >= x0:
                    L = [x] + longest(x, i+1)
                    if len(L) > len(best):
                        best = L
            _cache[x0, i] = best
            return best
    
    print longest(0, 0)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a sequence x1,x2,x3.....xn, and I want to find the longest continuous
I have an array like this: 0011011100011111001 I'd like to find the longest sequence
I have a list of lists, and I need to find the longest one
Given a string S of length N find longest substring without repeating characters. Example:
I'm implementing algorithms in http://portal.acm.org/citation.cfm?id=1813708 that utilize suffix arrays to find longest common substrings.
I want to find the longest possible sequence of words that match the following
I wrote the function to find longest common subsequence (LCS). For example, for two
I built this method to find the longest word in an array, but I'm
How do I find to find which array is the longest (highest count) out
...if that is possible My task is to find the longest streak of continuous

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.