Answer to Question #222467 in Java | JSP | JSF for Khushbu

Question #222467
The placement session has begun in a college. There is N number of students standing outside an interview room in a line. It is given that the person who goes first has higher chances of selection.
Each student has a number associated with them representing their problem-solving capability. The higher the capability the higher the chances of selection. Now every student wants to know the number of students ahead of him with higher problem-solving capability.
Input: 6(number of students) {4 , 9 , 5 , 3 , 2 , 10}
Output: {0 , 0 , 1 , 3 , 4 , 0}
1
Expert's answer
2021-08-02T07:15:56-0400




public class Main
{
    
    
	public static void main(String[] args) {
	    int [] students = {4,9,5,3,2,10};
	    int counter;
	    for(int i=0; i<6; i++){
	        counter = 0;
	        for(int j=0; j<i; j++){
	            if (students[j] > students[i]){
	                counter += 1;
	            }
	            
	        }
	        	System.out.print(counter+" ");
	    }
	
	}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

khushbu Rathore
02.08.21, 14:39

Thank you so much for your response it will be really helpful for me

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS