Skip to content

Commit d72e701

Browse files
committed
[Code refactor to improve the performance]: Have implemented the program to find the number of days to wait after the ith day to get a warmer temperature then current day.
1 parent b13c93b commit d72e701

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

.idea/workspace.xml

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/com/raj/DailyTemperatures.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ public static void main(String[] args) {
3333
// Logic.
3434
for (int i = 0; i < temperatures.length; i++) {
3535
for (int j = i + 1; j < ans.length; j++) {
36+
if (i != 0 && temperatures[i] == temperatures[i - 1]) {
37+
ans[i] = Math.max(ans[i - 1] - 1, 0);
38+
break;
39+
}
3640
if (temperatures[i] < temperatures[j]) {
3741
ans[i] = j - i;
3842
break;

0 commit comments

Comments
 (0)