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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T00:50:55+00:00 2026-06-18T00:50:55+00:00

(yes I’ve searched as much as I can..) Maybe I shouldn’t use sequence but

  • 0

(yes I’ve searched as much as I can..)
Maybe I shouldn’t use sequence but there’s no better way to describe it..

[revision: As stated in the answer section, subsequence is not the right description.
A pair of numbers is the right words!]

Given a sequence of numbers and define the size of a pair of numbers from the sequence as the distance between the two numbers. Obviously the largest pair is [the first number, the last number]. The question is to find the largest pair of numbers with order opposite to the [first,last] pair.

For example, if the sequence is {1,6,3,5,2,8} then the answer should be
[6,2] because the order of the [1,8] is increasing, and the largest pair with decreasing order is [6,2].

A side question is, can this be solved in a declarative way using SQL like statements? Specifically I am thinking of using LINQ to do it.

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-06-18T00:50:56+00:00Added an answer on June 18, 2026 at 12:50 am

    It is not the sort of problem that is suitable for SQL. It is also poorly phrased. You are really looking for pairs of numbers rather than subsequences, and the size is the distance between the two.

    It can be solved O(n) by scanning the sequence backwards, for the smallest number after a given point, and its position. This gives {1,2,2,2,2,8) and {0,4,4,4,4,5}. Then scanning this in parallel with the original sequences gives sizes of {0,3,2,1,0,0}, so the largest size is for the pair (6,2), which has a size of 3.

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

Sidebar

Related Questions

Yes, I know there is MonoDevelop . But what if I want to use
Yes, There's More Than One Way To Do It but there must be a
Yes, I have searched and tried many techniques, but nothing seems to work. Here
Yes, I know this question has been asked before, but I can't find an
Yes, this question has been asked before, but I don't feel there's been a
Yes I know connect-assets . But I hope the coffeescript files can be compiled
Yes, I know there's Voter tutorial in cookbook . But I'm looking for something
Yes, I know that in ASP.NET MVC you have to use ViewModels. But I'm
Yes, I know you could use regular objects as associative arrays in JavaScript, but
Yes, I want to use GIMP to create a transparent image with some text

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.