LCP61.h 700 B

123456789101112131415161718192021222324252627282930
  1. //
  2. // Created by 李洋 on 2024/6/21.
  3. //
  4. #ifndef LEETCODE_C_LCP61_H
  5. #define LEETCODE_C_LCP61_H
  6. # include <math.h>
  7. int getTemper(int *temperA, int i) {
  8. if (temperA[i + 1] == temperA[i]) {
  9. return 0;
  10. }
  11. return temperA[i + 1] < temperA[i] ? -1 : 1;
  12. }
  13. int temperatureTrend(int *temperatureA, int temperatureASize, int *temperatureB, int temperatureBSize) {
  14. int ans = 0, count = 0;
  15. for (int i = 0; i+1 < temperatureASize; ++i) {
  16. int a = getTemper(temperatureA, i);
  17. int b = getTemper(temperatureB, i);
  18. if (a == b) {
  19. count++;
  20. ans = fmax(ans, count);
  21. } else count = 0;
  22. }
  23. return ans;
  24. }
  25. #endif //LEETCODE_C_LCP61_H
备用站点 当前处于降级运行的备用站点,仅供应急访问,数据和功能可能不是最新。