forked from YearOfProgramming/2017Challenges
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7edefad
commit 1e81805
Showing
3 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from collections import Counter | ||
|
||
|
||
class Solution: | ||
def findTheDifference(self, s, t): | ||
|
||
s = dict(Counter(s)) | ||
t = dict(Counter(t)) | ||
|
||
for key in t.keys(): | ||
if key not in s.keys(): | ||
s[key] = 0 | ||
if s[key] - t[key] <= -1: | ||
return key | ||
|
||
|
||
if __name__ == '__main__': | ||
|
||
test_case = Solution() | ||
s, t = [input() for _ in range(2)] | ||
print('\n' + test_case.findTheDifference(s, t)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# Find The Difference | ||
###### Language Version (Python 3.6.0) | ||
|
||
### Compile | ||
|
||
``` | ||
python test.py | ||
``` | ||
``` | ||
python FindTheDifference.py | ||
``` | ||
|
||
### How To Use | ||
|
||
Run test.py to check against unit test | ||
|
||
Run FindTheDifference.py to test your own implementation | ||
- Enter two lines of input, both must be a lowercase string |
Large diffs are not rendered by default.
Oops, something went wrong.