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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:25:23+00:00 2026-05-22T02:25:23+00:00

In my small problem, I have n users and m equipments (m and n

  • 0

In my small problem, I have n users and m equipments (m and n ~ 50000). One user can use one and only one equipment at a time.

I have a list of records in this format [u, e, t], with t (time) sorted ascending. Each record mean user u is using equipment e at time t. The number of records is around 500 million. Assume that two nearest records with the same u and e mean that u is using e continuously. For example:

1, 2, 1  
3, 4, 1    
1, 2, 3
1, 2, 4 
1, 2, 5 
2, 6, 6
3, 2, 6  
3, 2, 8 

would mean user 1 uses equipment 2 from 1 to 5.

What i want to do is from this list, infer the shift time in this format: [u, e, st, et] which means user u uses equipment e from start time st to end time et.

Result for the sample data would be:

1, 2, 0, 5  
3, 4, 0, 6  
3, 2, 6, 8

(assuming time starts from 0 and end at max(t), and when a pair of (u, e) is first seen, u has already started using e since the beginning of time 0. Similar for the last records.)

Given the big list (500 million record) but small enough m and n, how could I do this most efficiently?

@Edit: Possible data inconsistencies:
1: If there’s only 1 record (so no end time) such as the case of [2, 6, 6] in the sample data:
— If that’s the only time user 2 and equipment 6 appear in the data set, then ignore the data point.
— If after that record, user 2 uses another equipment, let say 7 at 10, then 2 uses 6 from 6 to 10.
— If after that record, equipment 6 is used by another user, let say 10 at 11, then 2 uses 6 from 6 to 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-22T02:25:24+00:00Added an answer on May 22, 2026 at 2:25 am

    Define two structures (I know this is Java, but let’s assume a generic algorithm):

    struct user_record {
        int machine_idx;
        int start_time;
    }
    
    struct machine_record {
        int user_idx;
        int start_time;
    }
    

    Given that a user cannot be using more than one piece of equipment at the same time, you could create an array/vector of user_records, one for each user (you said this is ~ 50k, so this should be tractable), and an array/vector of machine_records, one for each machine. Initialise all elements’ idx members to -1 (to indicate not currently active).

    Then every time you encounter an input record, check the state of the corresponding idx fields in the user_record and machine_record arrays. There are three possibilities:

    1. Both are -1. This is a start point, so set those elements to “point” at each other, and record start_time in each one.
    2. Both are not -1, and consistent. This is an end-point, so simply create an output record, and reset those elements’ idx fields back to -1.
    3. At least one is not -1, but they are inconsistent. You will need to create two output records, overwrite the elements with the new values, and also set the corresponding old machine/user indices to -1.

    This is O(N) time (where N is the number of input records).

    Note: The output will be sorted by end-times.

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

Sidebar

Related Questions

I have a small problem here. I want to list my files from a
I have small problem with my .net 2.0 winforms application. I want to embed
I have a small problem with interfaces. Here it is in Pseudo code :
I have a small problem with a script. I want to have a default
I have a small problem with how should i think a... problem. I want
I'm having a small problem in Java. I have an interface called Modifiable. Objects
SQL to find duplicate entries (within a group) I have a small problem and
I have a small math problem I am trying to solve Given a number
Am working on a small problem and have spent quite a few hours trying
I have a small problem with some late additions to a project, mysql and

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.