import java.util.Map;
import java.util.Scanner;

public class Main {
    public static boolean isBigger(String s, String enemy) {
        int[] hash = new int[10];
        for (int i = 0; i < s.length(); i++) {
            hash[s.charAt(i) - '0']++;
        }
        int len = enemy.length();
        if (len < 5) {
            for (int i = enemy.charAt(0) - '0' + 1; i < 10; i++) {
                if (hash[i] >= len) {
                    return true;
                }
            }
            return false;
        } else {
            int start = enemy.charAt(0) - '0' + 1;
            int maxLength = 0;
            int nowLen = 0;
            for (int i = start; i < 10; i++) {
                if (hash[i] > 0) {
                    nowLen++;
                } else
                    nowLen = 0;
                maxLength = Math.max(nowLen, maxLength);
            }
            return maxLength >= 5;
        }
    }
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNext()) {
            String s = scanner.next();
            String enemy = scanner.next();
            String ans = isBigger(s, enemy) ? "YES" : "NO";
            System.out.println(ans);
        }
    }
}

该题考点:

(1)hash表

(2)最长递增子序列长度