Notice
Recent Posts
Recent Comments
Link
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
Tags
- TABLESPACE
- JDBC
- manifest.json
- java api
- custom hook
- react
- isSquare
- Debug
- codewar
- DB2
- type
- codewars
- useEffect
- react hook
- descendingOrder
- IBM
- TypeScript
Archives
- Today
- Total
taesik
Largest 5 digit number in a series 본문
fn largest_five_digit_number(num: &str) -> u32 {
(0..num.len() - 4).filter_map(|start| num[start..start+5].parse::<u32>().ok()).max().unwrap()
}
In the following 6 digit number:
283910
91 is the greatest sequence of 2 consecutive digits.
In the following 10 digit number:
1234567890
67890 is the greatest sequence of 5 consecutive digits.
fn largest_five_digit_number(num: &str) -> u32 {
(0..num.len() - 4).filter_map(|start| num[start..start+5].parse::<u32>().ok()).max().unwrap()
}'functions and trick > RUST' 카테고리의 다른 글
| return the number of vowels (0) | 2022.06.09 |
|---|---|
| Masking with # except last 4 string (0) | 2022.06.09 |
| Break camelCase (0) | 2022.06.06 |