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 6918703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:53:37+00:00 2026-05-27T09:53:37+00:00

for two given sequences say A and B how can one find the length

  • 0

for two given sequences say A and B how can one find the length of the longest common difference subsequence in them such that the difference between the adjacent elements in these sequences is same. E.g if

A = {2,4,6,12}

and

B = {4,8,14}

, then the longest common difference between A and B is {2,6,12} and {4,8,14} as the difference in adjacent temrs in both is same i.e.

{4,6}

so the length is 3.
Can longest common subsequence be applied here? or what can be the approach to this problem?
Thanks.

  • 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-27T09:53:38+00:00Added an answer on May 27, 2026 at 9:53 am

    You can transform your problem, by substracting each element in each list by the smallest element of the list.

    For example:

    in A you get : min(A) = 2 then A = {0,2,4,10}

    in B you get : min(B)=4 then B={0,4,10}

    and your problem is now to find the longest common subsequence.

    I guess you can find what you need to solve this problem on SO or anywhere on the web :

    Wikipedia article on longest subsequence

    Hope it helps


    EDIT

    @Saeed Amiri is right and my answer is true if and only if the smallest element of A and B are in the longest subsequence.

    So it gave me a new idea to solve this problem :

    Let D(i,j) be the length of the longest subsequence such that its smallest element in A is the ith element of A (sorted) and its smallest element in B is the jth element of B.

    then

    D(i,j) = | { A-A(i) } intersect {B – B(j) } |

    (notation : |A|=card(A))

    you need to find the max of D(i,j) over i and j and you know

    0<=D(i,j)<=min(|A|-i,|B|-j)

    so if you find D(i,j) = min(|A|-i,|B|-j) you don’t need to test for i’,j’ such that min(|A|-i’,|B|-j’)<= min(|A|-i,|B|-j)

    it’s not very efficient (in worst case it’s O(n*m)) but at least it corrects my mistake.

    it should work,

    hope it helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given two sequences of identifier, how to find the smallest operation sequence that will
Given two sets A and B, what is the common algorithm used to find
Given two colors and n steps, how can one calculate n colors including the
I'm attempting to write a basic dna sequencer. In that, given two sequences of
Say I have two sequences of numbers, A and B . How can I
I'm looking for an algorithm that given two permutations of a sequence (e.g. [2,
Given two tables, one for workers and one for tasks completed by workers, CREATE
Let's say that I've created two different program executables, e.g. in C++. For some
An interview question: Given two non-ordered integer sequences a and b , their size
Not homework. Given two strings S and T of same length. Given a set

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.