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

Peppo

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

Peppo

검색하기 폼
  • 분류 전체보기 (221)
    • Story (13)
    • iOS (143)
      • Error (11)
    • 알고리즘 (43)
    • ETC (7)
    • React-Native (0)
    • CS (Computer science) (3)
  • 방명록

Swift 알고리즘 (2)
[Swift 알고리즘] - 올바른 괄호 (Programmers)

오늘의 알고리즘 문제는 Stack / Queue에 관련된 문제였다.주어진 s에 괄호가 여/닫이 다 되는지 판단하고 답을 내는 문제였고,풀이는 아래와 같다.  https://school.programmers.co.kr/learn/courses/30/lessons/12909  내 풀이import Foundationfunc solution(_ s:String) -> Bool { var ans:Bool = false var tempArr: [String] = [] for bracket in s { if !tempArr.isEmpty && tempArr[tempArr.endIndex - 1] == "(" && bracket == ")" { tempArr.remove..

알고리즘 2024. 8. 9. 09:48
[Swift 알고리즘] - Stack으로 Queue만들기

문제 사진 구조체 Stack 2개를 사용해서 Queue의 기능을 구현 내 풀이 struct Stack { private var stack: [T] = [] public var isEmpty: Bool { return stack.isEmpty } public var count: Int { return stack.count } public mutating func push(_ el: T) { stack.append(el) } public mutating func pop() -> T? { return isEmpty ? nil : stack.popLast() } } struct Queue { var s1 = Stack() var s2 = Stack() public mutating func inQueue(_ el..

알고리즘 2022. 10. 14. 23:12
이전 1 다음
이전 다음
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
  • Peppo's Github
TAG
  • swift 고차함수
  • Swift 프로그래머스
  • swift protocol
  • 원티드 프리온보딩
  • Swift Error Handling
  • Swift 내림차순
  • swift reduce
  • Swift final
  • Swift 알고리즘
  • RIBs tutorial
  • Swift joined()
  • RTCCameraVideoCapturer
  • CS 네트워크
  • Swift RIBs
  • ios
  • Swift
  • removeLast()
  • Swift inout
  • swift (programmers)
  • Class
  • Combine: Asynchronous Programming with Swift
  • Swift Leetcode
  • iOS error
  • Swift ModernRIBs
  • 2023년 회고
  • Swift joined
  • swift programmers
  • swift property
  • Swift init
  • Swift 프로퍼티
more
«   2025/05   »
일 월 화 수 목 금 토
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 31
글 보관함

Blog is powered by Tistory / Designed by Tistory

티스토리툴바