https://leetcode.com/problems/find-the-difference/
| 4 | * https://leetcode.com/problems/find-the-difference/ |
| 5 | */ |
| 6 | public class Sanghoo { |
| 7 | |
| 8 | // 기존 많이 사용했던 알파벳별 개수를 이용하였습니다. |
| 9 | public char findTheDifference(String s, String t) { |
| 10 | char res = '0'; |
| 11 | int[] arr = new int[26]; |
| 12 | |
| 13 | for(int i=0; i<t.length(); i++) { |
| 14 | if(i < s.length()) { |
| 15 | arr[s.charAt(i)-'a']++; |
| 16 | } |
| 17 | arr[t.charAt(i)-'a']--; |
| 18 | } |
| 19 | |
| 20 | for(int i=0; i<arr.length; i++) { |
| 21 | if(arr[i] < 0) { |
| 22 | res = (char)(i+'a'); |
| 23 | break; |
| 24 | } |
| 25 | } |
| 26 | |
| 27 | return res; |
| 28 | } |
| 29 | |
| 30 | } |
nothing calls this directly
no outgoing calls
no test coverage detected