프로그래밍
프로그래머스 C# 문자열안에 문자열(string.Contains, P, J)
노마드선샤인
2022. 12. 29. 11:09
728x90
using System;
public class Solution {
public int solution(string str1, string str2) {
int answer = 0;
if(str1.Contains(str2))
{
answer =1;
}
else
{
answer = 2;
}
return answer;
}
}
파이썬
/////
def solution(str1, str2):
return 1 if str2 in str1 else 2
def solution(str1, str2):
return 1 + int(str2 not in str1)
자바
class Solution {
public int solution(String str1, String str2) {
return (str1.contains(str2)? 1: 2);
}
}
class Solution {
public int solution(String str1, String str2) {
if (str1.contains(str2))
{
return 1;
}
return 2;
}
}
728x90