- Strength to Increase Rep
- +0
- Strength to Decrease Rep
- -0
- Upvotes Received
- 0
- Posts with Upvotes
- 0
- Upvoting Members
- 0
- Downvotes Received
- 2
- Posts with Downvotes
- 2
- Downvoting Members
- 2
class Temp { static int []years={-80000,-79950,20,70,22,60,58,60,58,65,1950,2005}; public static int max_year(int x,int y) { int i=0; int j=0; int m=0; int n=0; int z=0; while(x<y) { z=(x+y)/2; for(i=0;i<=11;i=i+2) { if((years[i]<z) && (years[i+1]>x)) { m=m+1; } if((years[i]<y) && (years[i+1]>z)) { n=n+1; } } if(m>n) { y=z; } else { x=z; } } … |
|
class Temp22 { static int []years={-80000,-79950,20,70,22,60,58,60,58,65,1950,2005}; public static int[] findMaxdinosaur(int[] years) { int[] count = new int[(years.length)/2]; int i=0; int j=0; int k=0; for(i=0;i<years.length;i=i+2) { int m=0; { for(j=0;j<years.length;j=j+2) { if(years[i]>years[j+2]) { m=m+1; } } } { count[k]=m; k=k+1; } } return count; } public static void main(String...s) { int[] … |
|
We are given an array of 2n integers wherein each pair in this array of integers represents the year of birth and the year of death of a dinosaurs respectively. The range of valid years we want to consider is [-100000 to 2005]. For example, if the input was: -80000 … |