-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy path953.cpp
More file actions
25 lines (25 loc) · 746 Bytes
/
Copy path953.cpp
File metadata and controls
25 lines (25 loc) · 746 Bytes
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
class Solution {
public:
bool isAlienSorted(vector<string>& words, string order) {
vector<int> wordsN;
for(int i = 0; i < words.size(); i++){
int wordc = 0;
for(int j = 0; j < words[i].length(); j++){
for(int k = 0; k < 26; k++){
if(words[i][j] == order[k]){
wordc += (10000000 * (k) / (pow(10, j)));
break;
}
}
}
cout << wordc << endl;
wordsN.push_back(wordc);
}
for(int i = 1; i < wordsN.size(); i++){
if(wordsN[i] < wordsN[i - 1]){
return false;
}
}
return true;
}
};