Skip to content

Commit

Permalink
Merge branch 'neetcode-gh:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Ykhan799 authored Sep 22, 2022
2 parents 01ec551 + ad607dc commit 11f9a6c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion java/42-Trapping-Rain-Water.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public int trap(int[] heights) {
right[i] = Math.max(heights[i], max);
max = right[i];
}
System.out.println(Arrays.toString(right));

for (int i = 0; i < heights.length; i++) {
c = c + Math.min(left[i], right[i]) - heights[i];
}
Expand Down
5 changes: 5 additions & 0 deletions python/79-Word-Search.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def dfs(r, c, i):
path.remove((r, c))
return res

# To prevent TLE,reverse the word if frequency of the first letter is more than the last letter's
count = defaultdict(int, sum(map(Counter, board), Counter()))
if count[word[0]] > count[word[-1]]:
word = word[::-1]

for r in range(ROWS):
for c in range(COLS):
if dfs(r, c, 0):
Expand Down

0 comments on commit 11f9a6c

Please sign in to comment.