Skip to content

Commit a12ea61

Browse files
authored
Merge pull request #1237 from ivan1016017/april11
adding valid anagram
2 parents 138cf32 + 4fa239a commit a12ea61

2 files changed

Lines changed: 29 additions & 0 deletions

File tree

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from typing import List, Union, Collection, Mapping, Optional
2+
from abc import ABC, abstractmethod
3+
4+
class Solution:
5+
def isAnagram(self, s: str, t: str) -> bool:
6+
7+
lst_s = [c for c in s]
8+
lst_t = [c for c in t]
9+
10+
lst_s.sort()
11+
lst_t.sort()
12+
13+
return lst_s == lst_t
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import unittest
2+
from src.my_project.interviews.top_150_questions_round_15\
3+
.valid_anagram import Solution
4+
5+
class ValidAnagramTestCase(unittest.TestCase):
6+
7+
def test_is_valid_anagram(self):
8+
solution = Solution()
9+
output = solution.isAnagram(s="anagram", t="nagaram")
10+
self.assertTrue(output)
11+
12+
13+
def test_is_no_valid_anagram(self):
14+
solution = Solution()
15+
output = solution.isAnagram(s="rat", t="car")
16+
self.assertFalse(output)

0 commit comments

Comments
 (0)