大佬,请问我这样对不对啊 public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); String str = in.next(); Solution solution=new Solution(); System.out.println(solution.solu(str)); } public int solu(String str) { if (str.charAt(0) != '1') { return -1; } for (int i = 1; i < str.length(); i++) { if (str.charAt(i) != '3') { return -1; } } return str.length() - 1; } }
点赞 评论

相关推荐

明日Star:第一个项目修一修,点不用多3-4个,描述就是优化+指标量化。第二个项目换一下吧,换个agent
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务