mixStart
Problem:
Test Cases:
mixStart("mix snacks") → true
mixStart("pix snacks") → true
mixStart("piz snacks") → false
Solution:
public boolean mixStart(String str) {
if(str.length()<3)
{
return false;
}
if(str.length()>=3)
{
if(str.substring(1,3).equals("ix"))
{
return true;
}
}
return false;
}
Problem:
Return true if the given string begins with "mix", except the 'm' can be anything, so "pix", "9ix" .. all count.
Test Cases:
mixStart("mix snacks") → true
mixStart("pix snacks") → true
mixStart("piz snacks") → false
Solution:
public boolean mixStart(String str) {
if(str.length()<3)
{
return false;
}
if(str.length()>=3)
{
if(str.substring(1,3).equals("ix"))
{
return true;
}
}
return false;
}
No comments:
Post a Comment