File tree 3 files changed +58
-0
lines changed
3 files changed +58
-0
lines changed Original file line number Diff line number Diff line change 138
138
* [ 1528.重新排列字符串] ( LeetCode刷题之旅及题目解析/1528.重新排列字符串/1528.重新排列字符串.md )
139
139
140
140
* [ 面试题] ( 面试题/README.md )
141
+ * [ 面试题01] ( 面试题/面试题01/README.md )
142
+ * [ 02.判定是否互为字符重排] ( 面试题/面试题01/02.判定是否互为字符重排/02.判定是否互为字符重排.md )
141
143
* [ 面试题02] ( 面试题/面试题02/README.md )
142
144
* [ 02.返回倒数第k个节点] ( 面试题/面试题02/02.返回倒数第k个节点/02.返回倒数第k个节点.md )
143
145
* [ 03.删除中间节点] ( 面试题/面试题02/03.删除中间节点/03.删除中间节点.md )
Original file line number Diff line number Diff line change
1
+ ## 02. 判定是否互为字符重排
2
+ > https://leetcode-cn.com/problems/check-permutation-lcci/
3
+
4
+
5
+ ### Java
6
+ ``` java
7
+ /*
8
+ * @Author: Goog Tech
9
+ * @Date: 2020-08-29 16:59:28
10
+ * @LastEditTime: 2020-08-29 16:59:55
11
+ * @Description: https://leetcode-cn.com/problems/check-permutation-lcci/
12
+ * @FilePath: \leetcode-googtech\面试题01\#02. 判定是否互为字符重排\Solution.java
13
+ * @WebSite: https://algorithm.show/
14
+ */
15
+
16
+ class Solution {
17
+ public boolean CheckPermutation (String s1 , String s2 ) {
18
+ if (s1 == s2) return true ;
19
+ if (s1 == null || s2 == null || s1. length() != s2. length()) return false ;
20
+ char [] c1 = s1. toCharArray();
21
+ char [] c2 = s2. toCharArray();
22
+ Arrays . sort(c1);
23
+ Arrays . sort(c2);
24
+ for (int i = 0 ; i < c1. length; i++ ) {
25
+ if (c1[i] != c2[i]) {
26
+ return false ;
27
+ }
28
+ }
29
+ return true ;
30
+ }
31
+ }
32
+ ```
33
+
34
+ ### Python
35
+ ``` python
36
+ '''
37
+ Author: Goog Tech
38
+ Date: 2020-08-29 16:59:34
39
+ LastEditTime: 2020-08-29 16:59:48
40
+ Description: https://leetcode-cn.com/problems/check-permutation-lcci/
41
+ FilePath: \leetcode-googtech\面试题01\#02. 判定是否互为字符重排\Solution.py
42
+ WebSite: https://algorithm.show/
43
+ '''
44
+
45
+ class Solution (object ):
46
+ def CheckPermutation (self , s1 , s2 ):
47
+ """
48
+ :type s1: str
49
+ :type s2: str
50
+ :rtype: bool
51
+ """
52
+ return len (s1) == len (s2) and set (s1) == set (s2)
53
+ ```
Original file line number Diff line number Diff line change
1
+ <p style =" text-align :center ;font-size :25px " >
2
+ 📝 面试题01
3
+ </p >
You can’t perform that action at this time.
0 commit comments