Question d’entretien chez CA Technologies

How do you find the maximum element in an array without using any loops?

Réponses aux questions d'entretien

Utilisateur anonyme

6 févr. 2018

I gave the solution based on RECURSION.

Utilisateur anonyme

29 août 2018

public class Main { static int max=0; public static void main(String[] args) { int[] arr= new int[]{3,1,4,6,5}; System.out.println(findMax(arr,arr.length-1)); } private static int findMax(int[] arr,int i) { if(i==0) { return max; } if(arr[i]>max){ max=arr[i]; return findMax(arr,i-1); } return max; } }