美团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);
        }
    }
}
全部评论

相关推荐

07-18 18:05
门头沟学院 Java
挂了&nbsp;正式批求捞
投递滴滴等公司10个岗位
点赞 评论 收藏
分享
评论
3
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务