Java | Simple solution | No union find
Intuition\n Describe your first thoughts on how to solve this problem. \nMaintain a map of all lowercase characters where each character points to the smallest 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nMaintain a map of all lowercase characters where each character points to the smallest equivalent character at any given time. Update this map as we discover equivalences between the characters of strings `s1` and `s2`, one character at a time. Finally use this map to convert the `baseStr` to the smallest equivalent string.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. Create a map of all lowercase characters and initialize them to point to their own value.\n2. Iterate over each character of strings `s1` and `s2`.\n3. Look up the map for the smallest equivalent characters for both the characters of `s1` and `s2`.\n4. Replace all instances of the larger equivalent character with the smaller one all throughout the map.\n5. Now use the final state of the map to convert the `baseStr` one character at a time to the smallest equivalent string.\n\n# Complexity\n- N is the length of strings `s1` and `s2`\n- M is the length of string `baseStr`\n\n- Time complexity: $$O(N + M)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n  public String smallestEquivalentString(String s1, String s2, String baseStr) {\n    var map = new char[26];\n\n    for (var i=0; i<26; i++)\n      map[i] = (char) (\'a\' + i);\n\n    for (var i=0; i < s1.length(); i++) {\n      var a = map[s1.charAt(i) - \'a\'];\n      var b = map[s2.charAt(i) - \'a\'];\n\n      if (a == b) continue;\n\n      var a1 = a < b ? a : b;\n      var b1 = a < b ? b : a;\n\n      for (var j=0; j<26; j++)\n        if (map[j] == b1)\n          map[j] = a1;\n    }\n    var sb = new StringBuilder();\n\n    for (var i=0; i < baseStr.length(); i++)\n      sb.append(map[baseStr.charAt(i) - \'a\']);\n\n    return sb.toString();\n  }\n}\n```
['String', 'Java']