Skip to content

Instantly share code, notes, and snippets.

@amustaque97
Last active April 8, 2021 17:31
Show Gist options
  • Save amustaque97/34fd04f09bc691c97561671f5123662f to your computer and use it in GitHub Desktop.
Save amustaque97/34fd04f09bc691c97561671f5123662f to your computer and use it in GitHub Desktop.
Upsolving Question asked in Interview
/******************************************************************************
Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.
*******************************************************************************/
public class Main
{
public static void main(String[] args) {
int arr[] = { 900, 940, 950, 1100, 1500, 1800 };
int dep[] = { 910, 1100, 1120, 1130, 1900, 2000 };
int n = arr.length;
int count = 1, result = 1;
int i = 1, j = 0;
while (i < n && j < n) {
if (arr[i] <= dep[j]) {
count++;
i++;
}
else if (arr[i] > dep[j]) {
count--;
j++;
}
if (count > result)
result = count;
}
System.out.println(result);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment