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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:35:38+00:00 2026-06-16T09:35:38+00:00

Problem description is follows: There are n events for particular day d having start

  • 0

Problem description is follows:

There are n events for particular day d having start time and duration. Example:

e1 10:15:06 11ms (ms = milli seconds)
e2 10:16:07 12ms
......

I need to find out the time x and n. Where x is the time when maximum events were getting executed.

Solution I am thinking is:
Scanning all ms in day d. But that request total 86400000*n calculation. Example

Check at 00::00::00::001 How many events are running
Check at 00::00::00::002 How many events are running
Take max of Range(00::00::00::01,00::00::00::00)

Second solution I am thinking is:

For eventi in all events
   Set running_event=1
   eventj in all events Where eventj!=eventi
        if eventj.start_time in Range (eventi.start_time,eventi.execution_time)
           running_event++

And then take max of running_event

Is there any better solution for this?

  • 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-16T09:35:39+00:00Added an answer on June 16, 2026 at 9:35 am

    This can be solved in O(n log n) time:

    • Make an array of all events. This array is already partially sorted: O(n)
    • Sort the array: O(n log n); your library should be able to make use of the partial sortedness (timSort does that very well); look into distribution-based sorting algorithms for better expected running time.
      • Sort event boundaries ascending w.r.t. the boundary time
      • Sort event ends before sort starts if touching intervals are considered non-overlapping
        (Sort event ends after sort starts if touching intervals are considered overlapping)
    • Initialise running = 0, running_best = 0, best_at = 0
    • For each event boundary:
      • If it’s a start of an event, increment running
      • If running > running_best, set best_at = current event time
      • If it’s an end of an event, decrement running
    • output best_at
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Problem description: Read an xml file, traverse to a particular node (element), if it
I'm having a problem with this: -(id)initWithName:(NSString *)n description:(NSString *)d url:(NSString *)u { I'm
Ok here is my problem : Before i start the description, let me to
I'm having a hard time figuring this validation problem. I have one parent domain
Problem description : - Step 1: Take input FILE_NAME from user at main thread.
Short problem description: XCode 4.2 install right Target on device, but debug (run) always
The following is the problem description: let c[n] be the catalan number for n
This is my homework, but please read my problem description first. I have to
SHORT DESCRIPTION OF PROBLEM: I want to set the text of a searchbar without
Description: I have a problem regarding DataGridView . I need to show a Client_Name

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.