Skip to content

Commit 8384416

Browse files
committed
feat: add solutions to lc problem: No.1705
* Add solutions to lc problem: No.1705.Maximum Number of Eaten Apples * Update python solutions
1 parent 770b85e commit 8384416

File tree

276 files changed

+1101
-1003
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

276 files changed

+1101
-1003
lines changed

lcci/01.02.Check Permutation/README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Solution:
4444
n1, n2 = len(s1), len(s2)
4545
if n1 != n2:
4646
return False
47-
counter = collections.Counter()
47+
counter = Counter()
4848
for i in range(n1):
4949
counter[s1[i]] += 1
5050
counter[s2[i]] -= 1
@@ -84,16 +84,18 @@ class Solution {
8484
### **JavaScript**
8585

8686
```js
87-
var CheckPermutation = function(s1, s2) {
88-
let n1 = s1.length, n2 = s2.length;
89-
if (n1 != n2) return false;
90-
let counter = {};
91-
for (let i = 0; i < n1; i++) {
92-
let cur1 = s1.charAt(i), cur2 = s2.charAt(i);
93-
counter[cur1] = (counter[cur1] || 0) + 1;
94-
counter[cur2] = (counter[cur2] || 0) - 1;
95-
}
96-
return Object.values(counter).every(v => v == 0);
87+
var CheckPermutation = function (s1, s2) {
88+
let n1 = s1.length,
89+
n2 = s2.length;
90+
if (n1 != n2) return false;
91+
let counter = {};
92+
for (let i = 0; i < n1; i++) {
93+
let cur1 = s1.charAt(i),
94+
cur2 = s2.charAt(i);
95+
counter[cur1] = (counter[cur1] || 0) + 1;
96+
counter[cur2] = (counter[cur2] || 0) - 1;
97+
}
98+
return Object.values(counter).every((v) => v == 0);
9799
};
98100
```
99101

lcci/01.02.Check Permutation/README_EN.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class Solution:
4444
n1, n2 = len(s1), len(s2)
4545
if n1 != n2:
4646
return False
47-
counter = collections.Counter()
47+
counter = Counter()
4848
for i in range(n1):
4949
counter[s1[i]] += 1
5050
counter[s2[i]] -= 1
@@ -82,16 +82,18 @@ class Solution {
8282
### **JavaScript**
8383

8484
```js
85-
var CheckPermutation = function(s1, s2) {
86-
let n1 = s1.length, n2 = s2.length;
87-
if (n1 != n2) return false;
88-
let counter = {};
89-
for (let i = 0; i < n1; i++) {
90-
let cur1 = s1.charAt(i), cur2 = s2.charAt(i);
91-
counter[cur1] = (counter[cur1] || 0) + 1;
92-
counter[cur2] = (counter[cur2] || 0) - 1;
93-
}
94-
return Object.values(counter).every(v => v == 0);
85+
var CheckPermutation = function (s1, s2) {
86+
let n1 = s1.length,
87+
n2 = s2.length;
88+
if (n1 != n2) return false;
89+
let counter = {};
90+
for (let i = 0; i < n1; i++) {
91+
let cur1 = s1.charAt(i),
92+
cur2 = s2.charAt(i);
93+
counter[cur1] = (counter[cur1] || 0) + 1;
94+
counter[cur2] = (counter[cur2] || 0) - 1;
95+
}
96+
return Object.values(counter).every((v) => v == 0);
9597
};
9698
```
9799

lcci/01.02.Check Permutation/Solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ def CheckPermutation(self, s1: str, s2: str) -> bool:
33
n1, n2 = len(s1), len(s2)
44
if n1 != n2:
55
return False
6-
counter = collections.Counter()
6+
counter = Counter()
77
for i in range(n1):
88
counter[s1[i]] += 1
99
counter[s2[i]] -= 1

lcci/01.04.Palindrome Permutation/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
```python
3737
class Solution:
3838
def canPermutePalindrome(self, s: str) -> bool:
39-
counter = collections.Counter(s)
39+
counter = Counter(s)
4040
cnt = 0
4141
for val in counter.values():
4242
if (val & 1) == 1:

lcci/01.04.Palindrome Permutation/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
```python
2828
class Solution:
2929
def canPermutePalindrome(self, s: str) -> bool:
30-
counter = collections.Counter(s)
30+
counter = Counter(s)
3131
cnt = 0
3232
for val in counter.values():
3333
if (val & 1) == 1:

lcci/01.04.Palindrome Permutation/Solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Solution:
22
def canPermutePalindrome(self, s: str) -> bool:
3-
counter = collections.Counter(s)
3+
counter = Counter(s)
44
cnt = 0
55
for val in counter.values():
66
if (val & 1) == 1:

lcci/10.02.Group Anagrams/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
```python
5050
class Solution:
5151
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
52-
chars = collections.defaultdict(list)
52+
chars = defaultdict(list)
5353
for s in strs:
5454
k = ''.join(sorted(list(s)))
5555
chars[k].append(s)

lcci/10.02.Group Anagrams/README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
```python
4949
class Solution:
5050
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
51-
chars = collections.defaultdict(list)
51+
chars = defaultdict(list)
5252
for s in strs:
5353
k = ''.join(sorted(list(s)))
5454
chars[k].append(s)

lcci/10.02.Group Anagrams/Solution.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
class Solution:
22
def groupAnagrams(self, strs: List[str]) -> List[List[str]]:
3-
chars = collections.defaultdict(list)
3+
chars = defaultdict(list)
44
for s in strs:
55
k = ''.join(sorted(list(s)))
66
chars[k].append(s)

lcci/16.02.Words Frequency/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ wordsFrequency.get("pen"); //返回1
4343
class WordsFrequency:
4444

4545
def __init__(self, book: List[str]):
46-
self.counter = collections.Counter(book)
46+
self.counter = Counter(book)
4747

4848
def get(self, word: str) -> int:
4949
return self.counter[word]

0 commit comments

Comments
 (0)