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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T11:59:17+00:00 2026-05-20T11:59:17+00:00

I have 2 vectors, which contain, let’s say Person (name, surname, etc) objects. I

  • 0

I have 2 vectors, which contain, let’s say Person (name, surname, etc) objects. I want to take one of the vectors (let’s name it “large”) then for each element in this vector find corresponding element in second one (“small”) and merge some data from “small” vector element to the “large” vector element. This operation is very similar to left join in SQL terms, but with additional merge of the data. The easiest way is to make 2 cycles, but that will lead to O(n^2) time complexity. Can I do better with STL algorithms?

  • 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-20T11:59:18+00:00Added an answer on May 20, 2026 at 11:59 am

    If you sort the small vector, you can then get O(n log n) for the merge portion by scanning the large vector and use binary_search to find elements in the small vector.

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

Sidebar

Related Questions

I have two floating-point number vectors which contain the same values up to a
I'd like to know which solution could be faster. Let's say we have mB
So I have a container(any kind, probably std::map or std::vector) which contains objects of
Imagine I have a table which stores a series of sparse vectors. A sparse
Say I have a vector which has thousands of elements. What is the R
I have some numbers stored in a std::vector<int> . I want to find which
I have a std::vector<std::string> which would contain numbers and characters (single char). I would
I have a list of vectors which are time series of inequal length. My
so let's say i have a vector, wich contains 4 elemens [string elements]. I
I have a class called SparseMatrix which contain a private vector of type Cell.

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.