-
Notifications
You must be signed in to change notification settings - Fork 2
/
02_suffix_words.py
49 lines (33 loc) · 1.03 KB
/
02_suffix_words.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import unittest
question_02 = """
Given a query string s and a list of all possible words,
return all words that have s as a suffix.
Example 1:
Input:
s = “ed”
words = [“called”, “aged”, “land”]
Output:
[“called”, “aged”]
Explanation:
Only called and aged ends with ed.
Example 2:
Input:
s = “d”
words = [“helped”, “held”, “land”, “mat”, “cat”, “bold”]
Output:
[“helped”, “held”, “land”, “bold”]
Explanation:
All these words ends with d, except for “mat” and “cat”.
"""
# Implement the below function and run the program
def suffix_words(suffix, words):
pass
class TestSuffixWords(unittest.TestCase):
def test_1(self):
self.assertEqual(suffix_words(
'ed', ['called', 'aged', 'land']), ['called', 'aged'])
def test_2(self):
self.assertEqual(suffix_words(
'd', ['helped', 'held', 'land', 'mat', 'cat', 'bold']), ['helped', 'held', 'land', 'bold'])
if __name__ == '__main__':
unittest.main(verbosity=2)