-
205. Isomorphic Strings javaLeetCode_Study_Plan/LeetCode 75 2022. 9. 26. 22:54
https://leetcode.com/problems/isomorphic-strings/?envType=study-plan&id=level-1
class Solution { public boolean isIsomorphic(String s, String t) { HashMap<String, String> map = new HashMap<String, String>(); int i = 0; while (i < s.length()){ if (map.containsKey(String.valueOf(s.charAt(i)))){ if (!map.get(String.valueOf(s.charAt(i))).equals(String.valueOf(t.charAt(i)))){ return false; } } else{ if (map.containsValue(String.valueOf(t.charAt(i)))) return false; map.put(String.valueOf(s.charAt(i)), String.valueOf(t.charAt(i))); } i++; } return true; } }
좀 코드가 드러워서 찾아보니.. Char이 아니라 Character면 hashmap에서 쓸 수 있었다 으하하
'LeetCode_Study_Plan > LeetCode 75' 카테고리의 다른 글
206. Reverse Linked List java (0) 2022.10.05 392. Is Subsequence java (0) 2022.10.04 [LeetCode 75] 중간 점검 (0) 2022.10.02 724. Find Pivot Index java (1) 2022.09.25 1480. Running Sum of 1d Array java (0) 2022.09.25