본문 바로가기 메뉴 바로가기

김성현의 iOS 블로그

프로필사진
  • 글쓰기
  • 관리
  • 태그
  • 방명록
  • RSS

김성현의 iOS 블로그

검색하기 폼
  • 분류 전체보기 (17)
    • 가이드 (11)
    • 알고리즘 (1)
    • Swift 이론 (5)
  • 방명록

Leetcode (1)
[LeedCode] 13. Roman to Integer (Swift)

https://leetcode.com/problems/roman-to-integer/ 로마숫자를 정수로 변환하는 문제 class Solution { let integer: [Character: Int] = [ "I" :1, "V" :5, "X" :10, "L" :50, "C" :100, "D" :500, "M" :1000 ] func romanToInt(_ s: String) -> Int { var result = 0 var previous = 0 for roman in s.reversed() { let digit = integer[roman]! if digit >= previous { result += digit } else { result -= digit } previous = digit } retu..

알고리즘 2022. 4. 3. 19:19
이전 1 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG
  • 알고리즘
  • Leetcode
  • UI
  • Swift
  • networking
  • concurrent
  • SwiftUI
  • GCD
more
«   2026/04   »
일 월 화 수 목 금 토
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 29 30
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바