https://leetcode.com/problems/di-string-match/
| 4 | * https://leetcode.com/problems/di-string-match/ |
| 5 | */ |
| 6 | public class Sanghoo { |
| 7 | |
| 8 | public int[] diStringMatch(String s) { |
| 9 | int[] res = new int[s.length()+1]; |
| 10 | int head = 0; |
| 11 | int tail = s.length(); |
| 12 | |
| 13 | for(int i=0; i<s.length(); i++) { |
| 14 | char ch = s.charAt(i); |
| 15 | res[i] = ch=='I' ? head++ : tail--; |
| 16 | } |
| 17 | |
| 18 | // tail 값을 넣어도 상관 X, 안들어간 빈 값을 똑같이 가리킴 |
| 19 | res[s.length()] = head; |
| 20 | // res[s.length()] = tail; |
| 21 | |
| 22 | return res; |
| 23 | } |
| 24 | |
| 25 | } |
nothing calls this directly
no outgoing calls
no test coverage detected