[精讚] [會員登入]
653

determine strings that include numbers and spaces

differ from Highest and Lowest numbers inside strings that includes spaces

分享此文連結 //n.sfs.tw/15061

分享連結 determine strings that include numbers and spaces@外行中的外行
(文章歡迎轉載,務必尊重版權註明連結來源)
2021-05-07 22:09:26 最後編修
2021-04-28 14:57:23 By jung
 

在codewars上練習到的題目

get Highest and Lowest number from string of space separated numbers

本來想說用 Arrays.stream.mapToInt 再找出最大和最小二個int

後來解完發現有神人用 collectors 一行就完成了

記錄一下

IntSummaryStatistics summary = Arrays.stream(numbers.split(" "))
      .collect(Collectors.summarizingInt(n -> Integer.parseInt(n)));

    return String.format("%d %d", summary.getMax(), summary.getMin());
END

你可能感興趣的文章

determine strings that include numbers and spaces differ from Highest and Lowest numbers inside strings that includes spaces

隨機好文

縣市端IdP新增自訂首頁內容功能 合併本部主程式,手動於mongo內新增管理使用者資料

在windows server建立radius服務使用active directory帳號驗證 setup windows server to add radius service using active directory accounts for authentication

更新程式取消google recaptcha改用輸入驗證碼 update cnclibs to 0.0.8.6

在新版谷歌協作平台嵌入edimax或lass空氣盒子讀取數值並視覺化 embeeded javascript to read and visualized lass json value on new google site

更新程式環境到wildfly18+openjdk11-phase4: 認證程式更新 認證程式更新