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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:40:52+00:00 2026-05-27T13:40:52+00:00

This is an interview problem I was asked, and I am still trying to

  • 0

This is an interview problem I was asked, and I am still trying to figure out if a polynomial time algorithm for this exists :-

Given file sizes for seen and unseen movies in drive A and drive B, along with the free space in both of them,determine if you can move all the unseen movies in one drive and seen in the other, using only the free space in the drives. The only operation allowed is move(source, dest) where dest should have more free space than src file size.

boolean canSegregateSeenUnseen(Drive A, Drive B);
where Drive is {
List<Integer> seenMoviesFileSizes;
List<Integer> unseenMoviesFileSizes;
Integer freeSpace;
}

I thought of doing a BFS over all possible states achievable from the initial state, connecting states using the move operation, but that appears to be exponential.

Is there a better way ? Or can this be reduced to a non-polynomial time problem ?

  • 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-27T13:40:52+00:00Added an answer on May 27, 2026 at 1:40 pm

    One possibility: one of the files you have to move is exactly the same size as the total of free space on both drives (I’m not sure whether the question cares which drive ends up with the watched files and which the unwatched, but even if not then it’s still possible that there are two files of this size on the same drive, one watched and one unwatched. Or one on each drive, either both watched or both unwatched).

    Then “is it possible to get all the free space onto the destination drive at once?” is (in part) a subset-sum problem: “does there exist a subset of all the files whose sum is the size of the source drive?”

    So I don’t think this looks good for a polynomial time solution, although I admit I haven’t given a formal reduction of the subset-sum problem to this problem.

    Btw, even if this problem is NP-complete, it doesn’t necessarily follow that there’s no solution better than the brute force you describe.

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

Sidebar

Related Questions

I was given this question at a job interview recently and couldn't figure out
I was asked this problem in a interview: Best Time to Buy and Sell
Possible Duplicate: Help with algorithm problem from SPOJ Came across this interview question. Given
This is a question that I was asked on a job interview some time
I got this problem from an interview with Microsoft. Given an array of random
This is an interview problem that I am stuck on: Given a string consisting
I've been trying unsuccessfully to solve a problem I was asked during an interview,
I was given this problem in an interview. How would you have answered? Design
I came across this problem during an interview forum., Given an int array which
Can anyone please help me with the Algorithm for this problem (its an Interview

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.