Skip to content

Commit

Permalink
➕61
Browse files Browse the repository at this point in the history
  • Loading branch information
0xcaffebabe committed Jun 21, 2024
1 parent 16a4d09 commit fd56683
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,7 @@ LCP 07 | [LCP 07.传递信息](/%E7%AE%97%E6%B3%95/LCP/LCP%2007.%E4%BC%A0%E9%80%
LCP 17 | [LCP 17. 速算机器人](/%E7%AE%97%E6%B3%95/LCP/LCP%2017.%20%E9%80%9F%E7%AE%97%E6%9C%BA%E5%99%A8%E4%BA%BA)
LCP 44 | [LCP 44.开幕式焰火](/%E7%AE%97%E6%B3%95/LCP/LCP%2044.%E5%BC%80%E5%B9%95%E5%BC%8F%E7%84%B0%E7%81%AB/LCP%2044.%E5%BC%80%E5%B9%95%E5%BC%8F%E7%84%B0%E7%81%AB.java)
LCP 50 | [LCP 50.宝石补给](/%E7%AE%97%E6%B3%95/LCP/LCP%2050.%E5%AE%9D%E7%9F%B3%E8%A1%A5%E7%BB%99/LCP%2050.%E5%AE%9D%E7%9F%B3%E8%A1%A5%E7%BB%99.java)
LCP 61 | [LCP 61.气温变化趋势](/%E7%AE%97%E6%B3%95/LCP/LCP%2061.%E6%B0%94%E6%B8%A9%E5%8F%98%E5%8C%96%E8%B6%8B%E5%8A%BF/LCP%2061.%E6%B0%94%E6%B8%A9%E5%8F%98%E5%8C%96%E8%B6%8B%E5%8A%BF.java)
LCP 62 | [LCP 62.交通枢纽](/%E7%AE%97%E6%B3%95/LCP/LCP%2062.%E4%BA%A4%E9%80%9A%E6%9E%A2%E7%BA%BD/LCP%2062.%E4%BA%A4%E9%80%9A%E6%9E%A2%E7%BA%BD.java)
LCP 66 | [LCP 66.最小展台数量](/%E7%AE%97%E6%B3%95/LCP/LCP%2066.%E6%9C%80%E5%B0%8F%E5%B1%95%E5%8F%B0%E6%95%B0%E9%87%8F/LCP%2066.%E6%9C%80%E5%B0%8F%E5%B1%95%E5%8F%B0%E6%95%B0%E9%87%8F.java)
LCP 67 | [LCP 67.装饰树](/%E7%AE%97%E6%B3%95/LCP/LCP%2067.%E8%A3%85%E9%A5%B0%E6%A0%91/LCP%2067.%E8%A3%85%E9%A5%B0%E6%A0%91.java)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* @lc app=leetcode.cn id=LCP 61 lang=java
* @lcpr version=
*
* [LCP 61] 气温变化趋势
*
* 62/62 cases passed (1 ms)
* Your runtime beats 100 % of java submissions
* Your memory usage beats 45.2 % of java submissions (43.2 MB)
*/


// @lcpr-template-start

// @lcpr-template-end
// @lc code=start
class Solution {
public int temperatureTrend(int[] a, int[] b) {
int ans = 0;
int cnt = 0;
for(int i = 1; i < a.length; i++) {
if (a[i] - a[i - 1] < 0 && b[i] - b[i - 1] < 0)
cnt++;
else if (a[i] - a[i - 1] == 0 && b[i] - b[i - 1] == 0)
cnt++;
else if (a[i] - a[i - 1] > 0 && b[i] - b[i - 1] > 0)
cnt++;
else
cnt = 0;
ans = Math.max(cnt, ans);
}
return ans;
}
}
// @lc code=end



/*
// @lcpr case=start
// [21,18,18,18]\n[34,32,16,16,17]\n
// [5,10,16,-6,15,11]\n[16,22,23,23,25,3,-16]\n
// @lcpr case=end
// @lcpr case=start
// @lcpr case=end
*/

0 comments on commit fd56683

Please sign in to comment.