[精讚] [會員登入]
700

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

隨機好文

[NetBeans]如何從git下載專案改建為自己的專案 修改git專案

在ubuntu18.04桌面版安裝中文注音輸入法 如何在ubuntu桌面使用新酷音注音輸入法

如何用git log功能產生有固定格式的commit紀錄 how to create a git commit history log file with custom format

wireguard vpn setup and implementation 在UBUNTU20.04LTS server架設wireguard vpn讓ios及android裝置使用

在ESXI6.7修改系統時間 how to modify esxi system time setting for good