Pergunta de entrevista da empresa ADP

Write a program for finding the second highest number in a given array using JAVA

Respostas da entrevista

Sigiloso

14 de dez. de 2019

Since, I am from an ECE background, I have told them that I don't have adequate knowledge in syntax and programming with JAVA. I have asked the interviewer whether I can do it in python/C++. But he forced me to do it. Then I have written logic in python but here and there added somewhat (system.println /scan ) statements here and there and moved on to next question.

Sigiloso

18 de nov. de 2020

public class SecondLargestInArrayExample{ public static int getSecondLargest(int[] a, int total){ int temp; for (int i = 0; i a[j]) { temp = a[i]; a[i] = a[j]; a[j] = temp; } } } return a[total-2]; } public static void main(String args[]){ int a[]={1,2,5,6,3,2}; int b[]={44,66,99,77,33,22,55}; System.out.println("Second Largest: "+getSecondLargest(a,6)); System.out.println("Second Largest: "+getSecondLargest(b,7)); }}