[精讚] [會員登入]
388

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

我有話要說

>>

限制:留言最高字數1000字。 限制:未登入訪客,每則留言間隔需超過10分鐘,每日最多5則留言。

訪客留言

[無留言]

隨機好文

nginx+ssl+certbot安裝設定雜記 using certbot on nginx to setup https connection

如何在ubuntu 18.04上設定一開機就啟動virtualbox某個vm a way to setup ubuntu18.04 for start vm on boot

更新程式環境到wildfly18+openjdk11-phase3: 伺服器環境升級準備 upgrade jdk and wildfly on server

使用bash script 顯示及比較記憶體剩餘用量 How to get the available memory reported as a percentage then compare Numbers and Strings in Linux Shell Script

How to deal windows10 with lost bootloader issue 如何修復Windows 10 丟失UEFI引導 (bootloader)無法開機