Skip to content

Commit f210785

Browse files
committed
Array Program - Second Minimum
1 parent 7c0f0d2 commit f210785

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

InterviewPrograms/src/com/java/array/SecondMinimum.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,17 @@
1414
* The solution is, declare two variables
1515
* one variable to store minimum in the array
1616
* another variable to store second minimum
17+
*
18+
* assume 0th index value is minimum value
19+
* and 1st index value is 2nd min value
20+
* then iterate the array from index 2 to n
21+
* compare every index value with min variable
22+
* if it is less than min variable
23+
* then update both min and second min
1724
*
25+
* else check the ith value is less
26+
* than 2nd min, if it so,
27+
* then update only 2nd min variable with ith value
1828
*/
1929
public class SecondMinimum {
2030
public static void main(String[] args) {

0 commit comments

Comments
 (0)