employer cover photo
employer logo
employer logo

CA Technologies

Acquired by Broadcom

Is this your company?

CA Technologies interview question

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

Interview Answers

Anonymous

6 Feb 2018

I gave the solution based on RECURSION.

Anonymous

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; } }