diff --git a/best-time-to-buy-and-sell-stock/sonjh1217.swift b/best-time-to-buy-and-sell-stock/sonjh1217.swift new file mode 100644 index 0000000000..f03750ff8b --- /dev/null +++ b/best-time-to-buy-and-sell-stock/sonjh1217.swift @@ -0,0 +1,18 @@ +class Solution { + func maxProfit(_ prices: [Int]) -> Int { + var maxProfit = 0 + var minPrice = prices[0] + + for i in (1.. [[String]] { + var stringsByCount = [[Int]: [String]]() + + strs.map { str in + var countsByAlphabet = Array(repeating: 0, count: 26) + for char in str.unicodeScalars { + countsByAlphabet[Int(char.value) - 97] += 1 + } + stringsByCount[countsByAlphabet, default: []].append(str) + } + + return Array(stringsByCount.values) + } + //시간 O(n*L) L=string들의 평균 길이 + //공간 O(n*L) +} +