You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* added c++ solution for Find-The-Difference problem
* Added Find The Difference problem to README
Added Find The Difference problem to the Hashtable section
//time complexity O(n+m) where n and m are the number of input characters in each input string respectively
2
+
//space compexity is O(1) since there is a limit on number of possible unique characters
3
+
//loop through the first string and add a count of characters to hashmap
4
+
//loop through second string and for each letter lookup in hashmap. If found, decrement the count in the hasmap. If the count <0 for any letter then we have found our extra character
5
+
//else if the letter cannot be found in our hashmap, then this must be the extra character
6
+
//Otherwise if no differences can be found between the two input strings we just return null character
7
+
8
+
9
+
10
+
classSolution {
11
+
public:
12
+
charfindTheDifference(string s, string t) {
13
+
14
+
char returnChar= '\0';
15
+
std::unordered_map <char,int>ourMap;
16
+
17
+
//count the letters in the input string and add it to map
0 commit comments