package answer;
public class Solution {
public int[] solution(String[] keymap, String[] targets) {
int[] answer = new int[targets.length];
int acnt = 0;
// 타겟데이터 추출
for (int i = 0; i < targets.length; i++) {
char s[] = targets[i].toCharArray();
// 데이터 문자만큼반복
for (char c : s) {
int minidex = Integer.MAX_VALUE;
// 타겟 문자당 keymap의 위치를 찾아 반환
for (int j = 0; j < keymap.length; j++) {
acnt = keymap[j].indexOf(c);
// 문자가 존재하고 최소값일때 최소값변경
if (acnt > -1 && minidex > acnt) {
minidex = acnt;
}
}
// 문자가 있을경우 저장 없을경우 -1
if (minidex < Integer.MAX_VALUE && answer[i] != -1) {
answer[i] += minidex + 1;
} else {
answer[i] = -1;
}
}
}
return answer;
}
public static void main(String[] args) {
// TODO Auto-generated method stub
Solution s = new Solution();
String[] keymap = { "ABACD", "BCEFD" };
String[] targets = { "ABCD", "AABB" };
System.out.println(s.solution(keymap, targets));
}
}
select m1.MEMBER_NAME, r1.REVIEW_TEXT, date_format(r1.REVIEW_DATE,'%Y-%m-%d') as 'REVIEW_DATE'
from REST_REVIEW r1
inner join MEMBER_PROFILE m1
on r1.MEMBER_ID = m1.MEMBER_ID
where r1.MEMBER_ID in
(select MEMBER_ID
from
(select MEMBER_ID, count(MEMBER_ID) as 'MAX'
from REST_REVIEW
group by 1
order by 2 desc
limit 1) as a)
order by REVIEW_DATE,REVIEW_TEXT