File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
String/411.Minimum-Unique-Word-Abbreviation Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ class Solution {
24
24
int mask = masks[i].second ;
25
25
string a = abbr (target,mask);
26
26
int flag = 1 ;
27
-
27
+
28
28
for (auto word:Set)
29
29
{
30
30
string b = abbr (word, mask);
@@ -36,6 +36,7 @@ class Solution {
36
36
}
37
37
if (flag == 1 ) return a;
38
38
}
39
+ return " " ;
39
40
}
40
41
41
42
@@ -44,12 +45,12 @@ class Solution {
44
45
int count = 0 ;
45
46
for (int i=0 ; i<N; i++)
46
47
{
47
- if (((mask>>(N- 1 -i) )&1 )==1 )
48
+ if (((mask>>i )&1 )==1 )
48
49
count++;
49
50
else
50
51
{
51
52
int j = i+1 ;
52
- while (j<N && ((mask>>(N- 1 -j) )&1 )==0 )
53
+ while (j<N && ((mask>>j )&1 )==0 )
53
54
j++;
54
55
count++;
55
56
i = j-1 ;
@@ -65,12 +66,12 @@ class Solution {
65
66
66
67
for (int i=0 ; i<N; i++)
67
68
{
68
- if (((mask>>(N- 1 -i) )&1 )==1 )
69
+ if (((mask>>i )&1 )==1 )
69
70
result.push_back (A[i]);
70
71
else
71
72
{
72
73
int j = i+1 ;
73
- while (j<N && ((mask>>(N- 1 -j) )&1 )==0 )
74
+ while (j<N && ((mask>>j )&1 )==0 )
74
75
j++;
75
76
result += to_string (j-i);
76
77
i = j-1 ;
You can’t perform that action at this time.
0 commit comments