Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static List<String> solution(String panel, String[] codes) {
- List<String> results = new ArrayList<>();
- for (String code : codes) {
- int codeLength = code.length();
- boolean found = false;
- for (int i = 1; i <= codeLength; i++) {
- String indexStr = code.substring(0, i);
- String pattern = code.substring(i);
- int index = Integer.parseInt(indexStr);
- if (pattern.length() >= 1) {
- if (index < panel.length() && panel.substring(index).startsWith(pattern)) {
- results.add(pattern);
- found = true;
- } else {
- results.add("not found");
- }
- }
- }
- }
- return results;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement