Skip to content

Commit 4e555a3

Browse files
add 2016
1 parent 4fa86d2 commit 4e555a3

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ _If you like this project, please leave me a star._ ★
99
| # | Title | Solutions | Video | Difficulty | Tag
1010
|-----|----------------|---------------|--------|-------------|-------------
1111
|2018|[Check if Word Can Be Placed In Crossword](https://leetcode.com/problems/check-if-word-can-be-placed-in-crossword/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2018.java) ||Medium||
12+
|2016|[Maximum Difference Between Increasing Elements](https://leetcode.com/problems/maximum-difference-between-increasing-elements/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2016.java) ||Easy||
1213
|2012|[Sum of Beauty in the Array](https://leetcode.com/problems/sum-of-beauty-in-the-array/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2012.java) ||Medium||
1314
|2011|[Final Value of Variable After Performing Operations](https://leetcode.com/problems/final-value-of-variable-after-performing-operations/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2011.java) ||Easy||
1415
|2007|[Find Original Array From Doubled Array](https://leetcode.com/problems/find-original-array-from-doubled-array/)|[Java](../master/src/main/java/com/fishercoder/solutions/_2007.java) ||Medium||
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package com.fishercoder.solutions;
2+
3+
public class _2016 {
4+
public static class Solution1 {
5+
public int maximumDifference(int[] nums) {
6+
int maxDiff = -1;
7+
for (int i = 0; i < nums.length - 1; i++) {
8+
for (int j = i + 1; j < nums.length; j++) {
9+
if (nums[j] >= nums[i]) {
10+
maxDiff = Math.max(nums[j] - nums[i], maxDiff);
11+
}
12+
}
13+
}
14+
return maxDiff;
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)