Skip to content

Commit 15d742d

Browse files
authored
Merge pull request #1269 from ivan1016017/may13
adding
2 parents 392acd1 + b985d48 commit 15d742d

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

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: 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_16\
3+
.ransome_note import Solution
4+
5+
6+
class RansomeNoteTestCase(unittest.TestCase):
7+
8+
def test_is_ransome_note(self):
9+
solution = Solution()
10+
output = solution.canConstruct(ransomNote="aa", magazine="aab")
11+
self.assertTrue(output)
12+
13+
def test_is_no_ransome_note(self):
14+
solution = Solution()
15+
output = solution.canConstruct(ransomNote="a", magazine="b")
16+
self.assertFalse(output)

0 commit comments

Comments
 (0)