---
# System prepended metadata

title: door dash

---

# door dash
![](https://i.imgur.com/yMAg2xc.png)

```python=
def intelligentSubstring(s:str, charValue:str, k:int) -> int:
    dic = {}
    charValue = [c for c in charValue]
    for i, v in enumerate(charValue):
        dic[chr(ord('a')+i)] = v
    
    normalNumber = res = left = 0
    for right in range(len(s)):
        print(left, right, res, normalNumber)
        if dic[s[right]] == '0':
            normalNumber += 1
        while normalNumber > k:
            if dic[s[left]] == '0':
                normalNumber -= 1
            left += 1
        res = max(res, right - left + 1)
    return res


```
![](https://i.imgur.com/x9ymGyN.png)

```python=
def maxSlidingWindow(self, nums: List[int], k: int) -> List[int]:
    deque = collections.deque()
    res = []
    for i, num in enumerate(nums):
        while num > deque[-1]:
            deque.pop()
        
        deque.append(i)
        
        if deque[0] == i - k:
            deque.popleft()
    
        if i - k + 1 > 0:
            res.append(deque[0])
    return res
```

![](https://i.imgur.com/0RAu95Y.jpg)
```python=
def websitePagination(items: List[List[str]], sortParameter:int, sorOrder:0, itemsPerPage:int, pageNumber: int):
    sortItems = sorted(items, key= lambda item: item[sortParameter], reverse=sorOrder)
    return sortItems[pageNumber*itemsPerPage: pageNumber*itemsPerPage + itemsPerPage]
```
![](https://i.imgur.com/sqELmXM.png)
![](https://i.imgur.com/ng2psm5.png)
```python=
def findAbsoluteIndexDifference(nums: List[int]) -> List[int]:
    m = len(nums)
    res = [0] * m
    for i in range(m):
        for j in range(i, m):
            if i!=j and nums[i]==nums[j]:
                diff = abs(i-j)
                res[i] += diff
                res[j] += diff
    return res
```
[leetcode 1761](https://leetcode.com/problems/minimum-degree-of-a-connected-trio-in-a-graph/)
![](https://i.imgur.com/iU2awPJ.png)
```python=
def minTrioDegree(self, n: int, edges: List[List[int]]) -> int:
        graph = defaultdict(set)
        for a, b in edges:
            graph[a].add(b)
            graph[b].add(a)
            
        friendCounts = {n:len(graph[n]) for n in graph}

        res = float('inf')
        for n in graph:
            for m in graph[n]:
                for o in graph[n] & graph[m]:
                    res = min(res, friendCounts[n]+friendCounts[m]+friendCounts[o]-6)
                    graph[o].discard(n)
                graph[m].discard(n)
                        
        return res if res < inf else -1
```


[leetcode 547](https://leetcode.com/problems/number-of-provinces/)
![](https://i.imgur.com/NG89n6X.png)
```python=
def findCircleNum(self, isConnected: List[List[int]]) -> int:
        number = len(isConnected)
        
        def dfs(root: int):
            for neighbor in range(number):
                if isConnected[root][neighbor] == 1:
                    if neighbor not in visited:
                        visited.add(neighbor)
                        dfs(neighbor)
                    
        res = 0
        visited = set()
        for root in range(number):
            if root not in visited:
                dfs(root)
                visited.add(root)
                res += 1

        return res
```