IBM HACKERRANK CODING SOLUTIONS
Kanalga Telegram’da o‘tish
We provide help for all Exams... Anyone can contact me @AK_Coder for Exam clearance and interviews Trusted ✅
Ko'proq ko'rsatishMamlakat belgilanmaganToif belgilanmagan
4 420
Obunachilar
Ma'lumot yo'q24 soatlar
Ma'lumot yo'q7 kun
Ma'lumot yo'q30 kun
Postlar arxiv
🔴TCS 𝗜𝗥𝗔 tomorrow anyone need help🔴
✨Limited seats....
✨Book your seat now 🟢
🟢I will provide All 45-50 Crct MCQ +
Python/Java code All test case passed + Unix code working ☑️
🟢clear your IRA guaranteed 80+ ✅✅
🔴Get 60k incentives guaranteed
🟢anyone need help ping me @bulliea
🚨 check in this channel after helping we wil post here... @tcsira630
import java.util.Scanner;
import java.util.Arrays;
public class Solution {
public static void main(String args[]){
Student[] student=new Student[4];
Scanner sc=new Scanner(System.in);
for(int i=0;i<4;i++){
int a=sc.nextInt();sc.nextLine();
String b=sc.nextLine();
int c=sc.nextInt();sc.nextLine();
String d=sc.nextLine();
student[i]=new Student(a,b,c,d);
}
String input1=sc.nextLine();
Student obj1=getLowestStudent(student,input1);
if(obj1==null)
{
System.out.println("No such student found");
}
else
{
System.out.println(obj1.id);
System.out.println(obj1.name);
System.out.println(obj1.score);
System.out.println(obj1.collegename);
}
Student obj2=getSecondHighestScoredStudent(student);
if(obj2==null)
{
System.out.println("No such student found");
}
else
{
System.out.println(obj2.id);
System.out.println(obj2.name);
System.out.println(obj2.score);
System.out.println(obj2.collegename);
}
}
private static Student getSecondHighestScoredStudent(Student[] student) {
int arrofprice[]=new int[0];
for (int i = 0; i <4 ; i++) {
if(student[i].score%2!=0 && student[i].score>500 )
{
arrofprice=Arrays.copyOf(arrofprice,arrofprice.length+1);
arrofprice[arrofprice.length-1]=student[i].score;
}
}
Arrays.sort(arrofprice);
if(arrofprice.length>0)
{
int x = arrofprice[arrofprice.length - 2];
for (int i = 0; i < student.length; i++) {
if (student[i].score == x) {
return student[i];
}
}
}
return null;
}
private static Student getLowestStudent(Student[] student, String input1) {
int arrofprice[]=new int[0];
for (int i = 0; i <4 ; i++) {
if(student[i].collegename.equalsIgnoreCase(input1))
{
arrofprice=Arrays.copyOf(arrofprice,arrofprice.length+1);
arrofprice[arrofprice.length-1]=student[i].score;
}
}
Arrays.sort(arrofprice);
if(arrofprice.length>0)
{
int x = arrofprice[0];
for (int i = 0; i < student.length; i++) {
if (student[i].score == x) {
return student[i];
}
}
}
return null;
}
}
class Student {
int id;
String name;
int score;
String collegename;
public Student(int id,String name,int score,String collegename){
this.id=id;
this.name=name;
this.score=score;
this.collegename=collegename;
}
}
