"We can use dictionary to store cache items so that our read / write operations will be O(1).
Each time we read or update an existing record, we have to ensure the item is moved to the back of the cache. This will allow us to evict the first item in the cache whenever the cache is full and we need to add new records also making our eviction O(1)
Instead of normal dictionary, we will use ordered dictionary to store cache items. This will allow us to efficiently move items to back of the cache a"
Alfred O. - "We can use dictionary to store cache items so that our read / write operations will be O(1).
Each time we read or update an existing record, we have to ensure the item is moved to the back of the cache. This will allow us to evict the first item in the cache whenever the cache is full and we need to add new records also making our eviction O(1)
Instead of normal dictionary, we will use ordered dictionary to store cache items. This will allow us to efficiently move items to back of the cache a"See full answer
"we can use two pointer + set like maintain i,j and also insert jth character to set like while set size is equal to our window j-i+1 then maximize our answer and increase jth pointer till last index"
Kishor J. - "we can use two pointer + set like maintain i,j and also insert jth character to set like while set size is equal to our window j-i+1 then maximize our answer and increase jth pointer till last index"See full answer
"
from typing import List
def getnumberof_islands(binaryMatrix: List[List[int]]) -> int:
if not binaryMatrix: return 0
rows = len(binaryMatrix)
cols = len(binaryMatrix[0])
islands = 0
for r in range(rows):
for c in range(cols):
if binaryMatrixr == 1:
islands += 1
dfs(binaryMatrix, r, c)
return islands
def dfs(grid, r, c):
if (
r = len(grid)
"
Rick E. - "
from typing import List
def getnumberof_islands(binaryMatrix: List[List[int]]) -> int:
if not binaryMatrix: return 0
rows = len(binaryMatrix)
cols = len(binaryMatrix[0])
islands = 0
for r in range(rows):
for c in range(cols):
if binaryMatrixr == 1:
islands += 1
dfs(binaryMatrix, r, c)
return islands
def dfs(grid, r, c):
if (
r = len(grid)
"See full answer
"Arrays.sort(inputarray)
sliding window with a size of 2.
Check for the sum in the sliding window.
subtract the start when window moves"
Sridhar R. - "Arrays.sort(inputarray)
sliding window with a size of 2.
Check for the sum in the sliding window.
subtract the start when window moves"See full answer
"Clarfying questions :
When we say a decrease in users adding the bank accounts. I would like to understand how the users making payments within Venmo I assume they are either using their credit cards/debit cards?
I would like to understand why the Adding of Bank Accounts is integral to Venmo since the users are using the debit card and Credit Cards.
My understanding is when the payments happen through debit cards rails Venmo pays higher interchange fees and to Reduces any losses incurred"
Dev S. - "Clarfying questions :
When we say a decrease in users adding the bank accounts. I would like to understand how the users making payments within Venmo I assume they are either using their credit cards/debit cards?
I would like to understand why the Adding of Bank Accounts is integral to Venmo since the users are using the debit card and Credit Cards.
My understanding is when the payments happen through debit cards rails Venmo pays higher interchange fees and to Reduces any losses incurred"See full answer
"def traprainwater(height: List[int]) -> int:
n = len(height)
totalwaterlevel = 0
for i in range(n):
j = i+1
while j = n:
break
rows = j - i -1
intrwaterlevel = min(height[j], height[i]) * rows
for k in range(i+1, j):
intrwaterlevel -= height[k]
totalwaterlevel += intrwaterlevel
i = j
return totalwaterlevel"
Manoj R. - "def traprainwater(height: List[int]) -> int:
n = len(height)
totalwaterlevel = 0
for i in range(n):
j = i+1
while j = n:
break
rows = j - i -1
intrwaterlevel = min(height[j], height[i]) * rows
for k in range(i+1, j):
intrwaterlevel -= height[k]
totalwaterlevel += intrwaterlevel
i = j
return totalwaterlevel"See full answer