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

相关推荐

最近拿到了正浩的提前批offer感觉自己的实力得到了肯定,也给了我更多底气
搞机墨镜猫:正浩提前批官网好像就只有电力电子软硬件,哥们投的是这两个岗位吗
26届校招投递进展
点赞 评论 收藏
分享
积极的小学生不要香菜:你才沟通多少,没500不要说难
点赞 评论 收藏
分享
评论
3
收藏
分享

创作者周榜

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