Quantcast
Channel: Active questions tagged redis+java - Stack Overflow
Viewing all articles
Browse latest Browse all 2204

How to efficiently record and get the total handled time between a period while the thing is handled intermittently?

$
0
0

Imagine this scene, Your boss wants to know how long you spend time in front of your laptop between 2 p.m and 3 p.m. However, you may leave to have a snack or buy a cup of coffee. Is there a good algorithm or data structure to efficiently get the "working period" as accurately as possible? Some complicated situations I want to solve listed below.

  1. I leave at 1:59 p.m and come back at 2:03 p.m, thus I spent 3 minutes in front of my laptop.
  2. I leave at 2:59 p.m and come back(or never come back) at 3:03 p.m, thus I only spent 1 minute in front of my laptop between 2 p.m and 3 p.m.

Viewing all articles
Browse latest Browse all 2204

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>