2020-06-09から1日間の記事一覧

【LeetCode】Easy: Longest Common Prefix

Longest Common Prefix https://leetcode.com/problems/longest-common-prefix/ 回答 class Solution { func longestCommonPrefix(_ strs: [String]) -> String { var min = strs.min()! while min.count > 0 { if strs.filter({ $0.contains(min) }).count …

【LeetCode】Easy: Roman to Integer

Roman to Integer https://leetcode.com/problems/roman-to-integer/ 自分の回答 class Solution { func romanToInt(_ s: String) -> Int { var output: Int = 0 var s: String = s while !s.isEmpty { let firstTwo = s.prefix(2) switch firstTwo { case "…