Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 01eb355

Browse files
committed
modified: DSA/Arrays.class
modified: DSA/Arrays.java
1 parent 01b896c commit 01eb355

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

‎DSA/Arrays.class‎

-62 Bytes
Binary file not shown.

‎DSA/Arrays.java‎

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public static void main(String args[]){
5252
}
5353
5454
LINEAR SEARCH
55-
*/
55+
5656
5757
public class Arrays{
5858
public static int linearSearch(int number[], int key){
@@ -76,4 +76,25 @@ public static void main(String args[]){
7676
System.out.println("The key exists at index: "+ index);
7777
}
7878
}
79+
}
80+
81+
LARGEST NUMBER
82+
83+
*/
84+
85+
import java.util.*;
86+
public class Arrays{
87+
public static int largestNumber(int number[]){
88+
int lar = Integer.MIN_VALUE; // -infinity
89+
for (int i=0; i<number.length; i++) {
90+
if(lar < number[i]) {
91+
lar = number[i];
92+
}
93+
}
94+
return lar;
95+
}
96+
public static void main(String args[]){
97+
int number[] = {2,4,5,7,9,5,2,1,3,4};
98+
System.out.print("The Largest number is: " + largestNumber(number));
99+
}
79100
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /