Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 68616f8

Browse files
author
罗文斌
committed
[update](2023年11月16日 22:05:55): auto commit and push
1 parent d57bd03 commit 68616f8

File tree

9 files changed

+14
-24
lines changed

9 files changed

+14
-24
lines changed

‎.DS_Store

0 Bytes
Binary file not shown.

‎algorithm_templates/.DS_Store

0 Bytes
Binary file not shown.

‎algorithm_templates/array/array_examples.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ def peakIndexInMountainArray1(A):
1212
return i
1313

1414

15+
monetary recency
1516

1617
# binary search
1718
def peakIndexInMountainArray2(A):

‎algorithm_templates/binary_search/binary_search_examples.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def is_perfect_square(num: 'int') -> 'bool':
1414
elif mid * mid < num:
1515
low = mid + 1
1616
else:
17-
high = mid - 1
17+
high = mid - 1
1818
return False
1919

2020

‎algorithm_templates/dict/dict_examples.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,7 @@ def groupAnagrams1(strs):
4343
return ans.values()
4444

4545

46-
# [49] https://leetcode.com/problems/group-anagrams/
47-
# Given an array of strings, group anagrams together.
48-
#
49-
# categorize by count
50-
def groupAnagrams2(strs):
51-
ans = defaultdict(list)
52-
for s in strs:
53-
count = [0] * 26
54-
for c in s:
55-
count[ord(c) - ord('a')] += 1
56-
ans[tuple(count)].append(s)
57-
return list(ans.values())
46+
5847

5948

6049
# [36] https://leetcode.com/problems/valid-sudoku

‎algorithm_templates/string/string_examples.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -404,17 +404,17 @@ def validWordAbbreviation2(word, abbr):
404404
#
405405
# use dict
406406
def lengthLongestPath(input):
407-
maxlen = 0
408-
pathlen = {0: 0}
409-
for line in input.splitlines():
410-
# lstrip is better here
411-
name = line.lstrip('\t')
412-
depth = len(line) - len(name)
413-
if '.' in name:
414-
maxlen = max(maxlen, pathlen[depth] + len(name))
415-
else:
416-
pathlen[depth + 1] = pathlen[depth] + len(name) + 1
417-
return maxlen
407+
maxlen = 0
408+
pathlen = {0: 0}
409+
for line in input.splitlines():
410+
# lstrip is better here
411+
name = line.lstrip('\t')
412+
depth = len(line) - len(name)
413+
if '.' in name:
414+
maxlen = max(maxlen, pathlen[depth] + len(name))
415+
else:
416+
pathlen[depth + 1] = pathlen[depth] + len(name) + 1
417+
print( maxlen)
418418

419419

420420
# [157] https://leetcode.com/problems/read-n-characters-given-read4/

‎data_structure/__init__.py

Whitespace-only changes.

‎data_structure/maths/__init__.py

Whitespace-only changes.

‎data_structure/maths/tests/test_binary_search_examples.py

Whitespace-only changes.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /