Advertisement
rajeshinternshala

Untitled

Oct 17th, 2023
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.85 KB | None | 0 0
  1.    public static List<String> solution(String panel, String[] codes) {
  2.         List<String> results = new ArrayList<>();
  3.         for (String code : codes) {
  4.             int codeLength = code.length();
  5.             boolean found = false;
  6.             for (int i = 1; i <= codeLength; i++) {
  7.                 String indexStr = code.substring(0, i);
  8.                 String pattern = code.substring(i);
  9.                 int index = Integer.parseInt(indexStr);
  10.                 if (pattern.length() >= 1) {
  11.                     if (index < panel.length() && panel.substring(index).startsWith(pattern)) {
  12.                         results.add(pattern);
  13.                         found = true;
  14.                     } else {
  15.                         results.add("not found");
  16.                     }
  17.                 }
  18.             }
  19.         }
  20.         return results;
  21.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement