File tree Expand file tree Collapse file tree 3 files changed +47
-0
lines changed
0953-Verifying-an-Alien-Dictionary/cpp-0953 Expand file tree Collapse file tree 3 files changed +47
-0
lines changed Original file line number Diff line number Diff line change
1
+ cmake_minimum_required (VERSION 3.13 )
2
+ project (A )
3
+
4
+ set (CMAKE_CXX_STANDARD 11 )
5
+
6
+ add_executable (A main.cpp )
Original file line number Diff line number Diff line change
1
+ // / Source : https://leetcode.com/problems/verifying-an-alien-dictionary/
2
+ // / Author : liuyubobobo
3
+ // / Time : 2018-12-08
4
+
5
+ #include < iostream>
6
+ #include < vector>
7
+ #include < unordered_map>
8
+
9
+ using namespace std ;
10
+
11
+
12
+ // / Transform and Compare
13
+ // / Time Complexity: O(n)
14
+ // / Space Complexity: O(1)
15
+ class Solution {
16
+ public:
17
+ bool isAlienSorted (vector<string>& words, string order) {
18
+
19
+ unordered_map<char , char > map;
20
+ for (int i = 0 ; i < order.size (); i ++)
21
+ map[order[i]] = ' a' + i;
22
+
23
+ for (string&word: words)
24
+ for (char & c: word)
25
+ c = map[c];
26
+
27
+ for (int i = 1 ; i < words.size (); i ++)
28
+ if (words[i - 1 ] > words[i])
29
+ return false ;
30
+ return true ;
31
+ }
32
+ };
33
+
34
+
35
+ int main () {
36
+
37
+ return 0 ;
38
+ }
Original file line number Diff line number Diff line change @@ -612,4 +612,7 @@ email: [liuyubobobo@gmail.com](mailto:liuyubobobo@gmail.com)
612
612
| 950 | [ Reveal Cards In Increasing Order] ( https://leetcode.com/problems/reveal-cards-in-increasing-order/ ) | [ solution] ( https://leetcode.com/problems/reveal-cards-in-increasing-order/solution/ ) | [ C++] ( 0950-Reveal-Cards-In-Increasing-Order/cpp-0950/ ) | | |
613
613
| 951 | [ Flip Equivalent Binary Trees] ( https://leetcode.com/problems/flip-equivalent-binary-trees/ ) | [ solution] ( https://leetcode.com/problems/flip-equivalent-binary-trees/solution/ ) | [ C++] ( 0951-Flip-Equivalent-Binary-Trees/cpp-0951/ ) | | |
614
614
| 952 | [ Largest Component Size by Common Factor] ( https://leetcode.com/problems/largest-component-size-by-common-factor/ ) | [ solution] ( https://leetcode.com/problems/largest-component-size-by-common-factor/solution/ ) | [ C++] ( 0952-Largest-Component-Size-by-Common-Factor/cpp-0952/ ) | | |
615
+ | 953 | [ isAlienSorted] ( https://leetcode.com/problems/verifying-an-alien-dictionary/ ) | [ solution] ( https://leetcode.com/problems/verifying-an-alien-dictionary/solution/ ) | [ C++] ( 0953-isAlienSorted/cpp-0953/ ) | | |
616
+ | | | | | | |
617
+ | | | | | | |
615
618
| | | | | | |
You can’t perform that action at this time.
0 commit comments