日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

452 Minimum Number of Arrows to Burst Balloons

發布時間:2025/1/21 编程问答 20 豆豆
生活随笔 收集整理的這篇文章主要介紹了 452 Minimum Number of Arrows to Burst Balloons 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

452 Minimum Number of Arrows to Burst Balloons

文章目錄

  • 452 Minimum Number of Arrows to Burst Balloons
    • 1:題目描述
    • 2:解決思路
    • 3:代碼
    • 4:正數負數相減超出范圍(問題)
    • 5:50%

1:題目描述

2:解決思路

  • 先排序,從小到大
  • 開始 < END 則 整個__開始 = 開始
  • 結尾 < END 則 整個 __結尾 = 結尾
  • 否則
    • NUM++
    • 整個__開始 = 新的開始
    • 整個__結尾 = 新的結尾

3:代碼

class Solution {public int findMinArrowShots(int[][] points) {if(points==null || points.length ==0) return 0;Arrays.sort(points, new Comparator<int[]>() {@Overridepublic int compare(int[] o1, int[] o2) {if(o1[0] <o2[0]) return -1;return 1;}});int result=1,begin=points[0][0],end=points[0][1];for(int i=1;i<points.length;i++){if(points[i][0] <= end){begin=points[i][0];if(points[i][1] < end){end=points[i][1];}}else{result++;begin=points[i][0];end=points[i][1];}}return result;} }

4:正數負數相減超出范圍(問題)

Arrays.sort(points, new Comparator<int[]>() {@Overridepublic int compare(int[] o1, int[] o2) {return o1[0]-o2[0];}}); public int compare(int[] o1, int[] o2) {if(o1[0] <o2[0]) return -1;return 1;}
  • 不用減法 直接比較大小

5:50%

總結

以上是生活随笔為你收集整理的452 Minimum Number of Arrows to Burst Balloons的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。