employer cover photo
employer logo
employer logo

CA Technologies

Übernommen von Broadcom

Ist dies Ihr Unternehmen?

Frage im Vorstellungsgespräch bei CA Technologies

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

Antworten zu Vorstellungsgespräch

Anonym

6. Feb. 2018

I gave the solution based on RECURSION.

Anonym

29. Aug. 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; } }