Skip to content

Instantly share code, notes, and snippets.

@DongguemYoo
Created May 2, 2020 06:50
Show Gist options
  • Save DongguemYoo/1b8e8fcfe441b65e92efedd75b1a00c8 to your computer and use it in GitHub Desktop.
Save DongguemYoo/1b8e8fcfe441b65e92efedd75b1a00c8 to your computer and use it in GitHub Desktop.
코딩테스트 연습 수박수박수박수?
//내가 푼 방식
public class Solution {
public string solution(int n) {
string answer = "";
string pattern1 = "수";
string pattern2 = "박";
for(int i=0;i<n;i++)
{
if(i%2==0)
answer+=pattern1;
else
answer+=pattern2;
}
return answer;
}
}
//다른사람이 푼 방식
//이항연산자를 사용해서 풀었다!!
//나도 이항연산자를 좀 사용하자아~
public class Solution {
public string solution(int n) {
string answer = "";
for(int i=0;i<n;i++)
{
answer+= i%2==0?"수":"박";
}
return answer;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment