keep learning, keep coding!
Problem - Isomorphic Strings
Given two strings s and t, determine if they are isomorphic.
Two strings s and t are isomorphic if the characters in s can be replaced to get t.
All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character, but a character may map to itself.
翻譯蒟蒻
給定兩個字串 s 和 t,要判斷是否同構。
也就是說所有字的出現都必須被替換為另一個字,同時保持字的順序,且不能有兩個字映射到同一個字,但一個字可以映射到自己。
- Example 1: - 1 
 2- Input: s = "egg", t = "add" 
 Output: true
- Example 2: - 1 
 2- Input: s = "foo", t = "bar" 
 Output: false
- Example 3: - 1 
 2- Input: s = "paper", t = "title" 
 Output: true
Solution - JavaScript
| 1 | /** | 
Solution - Ruby
| 1 | def is_isomorphic(s, t) | 
Solution - PHP
| 1 | function isIsomorphic($s, $t) { | 
PHP 方法筆記
- 在 PHP 中,沒有直接內建的 Map 類型,而是使用關聯數組(Associative Arrays)作為主要的映射結構。 - 1 - $map = array(); // 或者 $map = []; - 使用這個$map陣列來儲存鍵值對。
 - 1 
 2- $map['key1'] = 'value1'; 
 $map['key2'] = 'value2';
- 使用這個