[精讚] [會員登入]
652

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

隨機好文

[網管心得]qnap+proxmox 韌體更新及nfs掛載或變更

debian安裝drupal細節 設定apache2的細節

[java]縣市IDP建置 使用NetBeans建置IDP程式

設定win10開機自動執行openvpn連接vpn server how to make win10 connecting to a vpn server automactically after booting up

安裝netbeans9遇到的小狀況 how to show netbeans9 program onto ubuntu desktop