public class TheSong {
public String solution(String m, String[] musicinfos) {
String answer = "(None)";
m = m.replace("C#", "c");
m = m.replace("D#", "d");
m = m.replace("F#", "f");
m = m.replace("G#", "g");
m = m.replace("A#", "a");
int max = 0;
for (int i = 0; i < musicinfos.length; i++) {
String[] info = musicinfos[i].split(",");
int before = Integer.parseInt(info[0].split(":")[0]) * 60 + Integer.parseInt(info[0].split(":")[1]);
int after = Integer.parseInt(info[1].split(":")[0]) * 60 + Integer.parseInt(info[1].split(":")[1]);
info[3] = info[3].replace("C#", "c");
info[3] = info[3].replace("D#", "d");
info[3] = info[3].replace("F#", "f");
info[3] = info[3].replace("G#", "g");
info[3] = info[3].replace("A#", "a");
String[] melody = info[3].split("");
String total_melody = "";
for (int j = 0; j < after - before; j++) {
total_melody += melody[j % melody.length];
}
if (total_melody.contains(m)) {
if (max < after - before) {
max = after - before;
answer = info[2];
}
}
}
return answer;
}
}