Skip to content

Commit

Permalink
add a type-2 solution of python
Browse files Browse the repository at this point in the history
add a type-2 solution of python
  • Loading branch information
yehjames committed Jan 20, 2016
1 parent 7d5bba4 commit 9812192
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions zh-hans/string/anagrams.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,28 @@ private:
**leetcode 上此题的 signature 已经更新,需要将 anagrams 按组输出,稍微麻烦一点点。**
### Python lintcode
```python
class Solution:
# @param strs: A list of strings
# @return: A list of strings
# @return: A list of strings
def anagrams(self, strs):
strDict={}
result=[]
for string in strs:
if "".join(sorted(string)) not in strDict.keys():
strDict["".join(sorted(string))] = 1
else:
strDict["".join(sorted(string))] += 1
for string in strs:
if strDict["".join(sorted(string))] >1:
result.append(string)
return result
```


### C++ - lintcode

```c++
Expand Down

0 comments on commit 9812192

Please sign in to comment.