Skip to content

[Algorithm] StrSymmetryPoint 문제 풀이 #160

Description

@hwangJi-dev

💬 문제

https://app.codility.com/programmers/trainings/4/str_symmetry_point/


💬 Idea

  • 중간 인덱스까지 비교하며 같지 않다면 return -1, 같다면 mid를 리턴한다.

💬 풀이

publicfunc solution(_ S :inoutString)->Int{ifS.count %2==0{return-1}letmid=S.count /2varstart=0varend=S.count -1lets=Array(S).map({String($0)})while start < mid {ifs[start]!=s[end]{return-1}
start +=1
end -=1}return mid
}

효율성 0점 풀이 : https://app.codility.com/demo/results/trainingDY7DPQ-PFH/

100점 풀이 : https://app.codility.com/demo/results/trainingZNRGGS-24G/

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions