You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2.
5
+
6
+
Note:
7
+
8
+
The length of both num1 and num2 is < 5100.
9
+
10
+
Both num1 and num2 contains only digits 0-9.
11
+
12
+
Both num1 and num2 does not contain any leading zero.
13
+
14
+
You MUST NOT convert the inputs to integer directly.
15
+
16
+
Complete the addStrings function. It takes the input as two strings & you need to return the string (which will same as the addition of two number as integers).
International Morse Code defines a standard encoding where each letter is mapped to a series of dots and dashes, as follows: "a" maps to ".-", "b" maps to "-...", "c" maps to "-.-.", and so on.
5
+
6
+
For convenience, the full table for the 26 letters of the English alphabet is given below:
Now, given a list of words, each word can be written as a concatenation of the Morse code of each letter. For example, "cab" can be written as "-.-..--...", (which is the concatenation "-.-." + ".-" + "-..."). We'll call such a concatenation, the transformation of a word.
10
+
11
+
Return the number of different transformations among all words we have.
12
+
13
+
Input format
14
+
First line contains a positive integer n, denoting the number of test cases. It is followed by n lines. Each of the n lines contains space separated words.
15
+
16
+
Output format
17
+
n lines containing the number of different transformations among all words we have.
18
+
19
+
Sample input
20
+
1
21
+
gin zen gig msg
22
+
Sample output
23
+
2
24
+
Explanation
25
+
The transformation of each word is:
26
+
27
+
"gin" -> "--...-."
28
+
29
+
"zen" -> "--...-."
30
+
31
+
"gig" -> "--...--."
32
+
33
+
"msg" -> "--...--."
34
+
35
+
There are 2 different transformations, "--...-." and "--...--.".
36
+
37
+
Note
38
+
The length of words will be at most 100000
39
+
40
+
Each words[i] will have length in range [1, 12].
41
+
42
+
words[i] will only consist of lowercase letters.
43
+
44
+
"""
45
+
#a=97
46
+
#z=97+25=122 ord("z")
47
+
########################### BY USING DICT ######################
0 commit comments