deno.land / x / masx200_leetcode_test@10.6.5 / check-permutation-lcci / index.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
export default function CheckPermutation(s1: string, s2: string): boolean { if (s1.length !== s2.length) { return false; } const table: number[] = new Array(26).fill(0); for (let i = 0; i < s1.length; ++i) { table[s1.charCodeAt(i) - "a".charCodeAt(0)]++; } for (let i = 0; i < s2.length; ++i) { table[s2.charCodeAt(i) - "a".charCodeAt(0)]--; if (table[s2.charCodeAt(i) - "a".charCodeAt(0)] < 0) { return false; } } return true;}
masx200_leetcode_test
leetcode题解和一些测试工具
DocumentationDocumentation
GitHub Repositorymasx200/leetcode-test
GitHub Stars
4

Version Info

Tagged at
4 months ago