Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static int solve(List<Integer> login, List<Integer> logout) {
- int max = 0;
- for (int x : logout) {
- max = Math.max(x, max);
- }
- int dp[] = new int[max + 2];
- for (int x : login) {
- dp[x]++;
- }
- for (int x : logout) {
- dp[x + 1]--;
- }
- int maxNumber = 0;
- for (int i = 2; i < dp.length; i++) {
- dp[i] += dp[i - 1];
- maxNumber = Math.max(dp[i], maxNumber);
- }
- int ans = 0;
- for (int x : dp) {
- if (x == maxNumber) ans++;
- }
- return ans;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement