[精讚] [會員登入]
793

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

隨機好文

使用virtualbox每次都忘記的事情 share folder from win host to linux guest vm

在windows環境下強制刪除無法以檔案總管刪除的檔案或目錄 how to remove directories or files that cannot be deleted by default file manager

更新java版本後一定要做的事情 how to deal with PKIX path building failed issue after upgrade java sdk version in IDE

how to add physical disks into HP smart array through esxi interface 如何在磁碟陣列卡上加入新的硬碟-未完待續

unknown issue after downgrade to intellij idea community version 使用社群版遇到的奇怪問題