프로그래머스(3)
-
[Programmers] 튜플 Swift
프로그래머스 튜플 Swift 내 풀이 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 import Foundation func solution(_ s:String) -> [Int] { var dic = [Int:Int]() var result = [Int]() var input = s.replacingOccurrences(of: "{", with: "") input = input.replacingOccurrences(of: "}", with: "") var data = input.split{$0 == ","}.map{Int(String($0))!} for i in data { if dic[i] != nil { dic[i]! += 1 } else { dic[i] ..
2023.06.19 -
[Python] [Algorithm] 리스트에서 가장 큰 수 / 가장 작은 수 찾기
map = [1,2,3,20,5,6,7,8,9,10,11] l = len(map) max = 0 for key in range(0,l): print("key :", key, "value :", map[key], "max :", max) if map[key] > max: max = map[key] print("max :", max) min = max for key in range(0,l): print("key :", key, "value :", map[key], "min :", min) if map[key] < min: min = map[key] print("min :", min)
2021.06.24 -
[Python] [Algorithm] 가장 많이 등장하는 알파벳 갯수 세기
word = "chanhhh" def highFrequencyLetterCount(word): map = {} for alphabet in word: print("map :",map) if map.get(alphabet) == None: map[alphabet] = 1 else: map[alphabet] += 1 print(map) max = -1 for key in map: print("key :", key, "value :", map[key], "max :", max) if map[key] > max: max = map[key] print(max) return max highFrequencyLetterCount(word)
2021.06.24