美团2024年春招第一场笔试【技术】
//小美的 MT
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
List<Character> list = new ArrayList<>();
String s = sc.next();
int l = 0;
for (int i = 0; i < n; i++) {
char c = s.charAt(i);
if (c == 'M' || c == 'T') {
l++;
}
}
if (l + k > n) {
System.out.println(n);
} else {
System.out.println(l + k);
}
}
}
import java.util.Scanner;
import java.util.ArrayList;
import java.util.List;
// 注意类名必须为 Main, 不要有任何 package xxx 信息
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();
List<Character> list = new ArrayList<>();
String s = sc.next();
int l = 0;
for (int i = 0; i < n; i++) {
char c = s.charAt(i);
if (c == 'M' || c == 'T') {
l++;
}
}
if (l + k > n) {
System.out.println(n);
} else {
System.out.println(l + k);
}
}
}
全部评论
相关推荐

点赞 评论 收藏
分享
05-21 14:50
湖南机电职业技术学院 前端工程师 nus2201602...:兄弟,你这个简历撕了丢了吧,就是一坨,去找几个项目,理解项目流程,看几遍就是你的了,看看八股就去干了,多看看牛客里别人发出来的简历,对着写,你这写的啥啊,纯一坨

点赞 评论 收藏
分享