Skip to content

Commit fa7ee13

Browse files
committed
adding ransome note
1 parent bb3cdbf commit fa7ee13

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
from typing import List, Union, Collection, Mapping, Optional
2+
from abc import ABC, abstractmethod
3+
4+
class Solution:
5+
def canConstruct(self,ransomNote: str, magazine: str) -> bool:
6+
7+
for c in set(ransomNote):
8+
9+
if ransomNote.count(c) > magazine.count(c):
10+
return False
11+
12+
return True
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import unittest
2+
from src.my_project.interviews.top_150_questions_round_15\
3+
.ransome_note import Solution
4+
5+
class RansomeNoteTestCase(unittest.TestCase):
6+
7+
def test_is_ransome_note(self):
8+
solution = Solution()
9+
output = solution.canConstruct(ransomNote="aa", magazine="aab")
10+
self.assertTrue(output)
11+
12+
def test_is_no_ransome_note(self):
13+
solution = Solution()
14+
output = solution.canConstruct(ransomNote="a", magazine="b")
15+
self.assertFalse(output)

0 commit comments

Comments
 (0)