MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / solve

Method solve

FirstThreeLargest.java:7–30  ·  view source on GitHub ↗
(int arr[])

Source from the content-addressed store, hash-verified

5 solve(arr);
6 }
7 public static void solve(int arr[])
8 {
9 int n=arr.length;
10 int first = Integer.MIN_VALUE, second=Integer.MIN_VALUE,third=Integer.MIN_VALUE;
11 for(int i=0;i<n;i++)
12 {
13 if(first<=arr[i])
14 {
15 third = second;
16 second = first;
17 first = arr[i];
18 }
19 else if(second<=arr[i])
20 {
21 third = second;
22 second = arr[i];
23 }
24 else if(third<=arr[i])
25 {
26 third = arr[i];
27 }
28 }
29 System.out.println(first + " " + second + " "+ third);
30 }
31}

Callers 1

MainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected