새소식

인기 검색어

프로그래머스/Lv.1

[Swift] 문자열 내 p와 y의 개수

  • -
import Foundation

func solution(_ s:String) -> Bool
{
    let string = s.lowercased()
    return string.components(separatedBy: "p").count == string.components(separatedBy: "y").count
}

 

Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.