# Solution of Biweekly Contest 17

## [Easy] 1313. Decompress Run-Length Encoded List

We are given a list `nums` of integers representing a list compressed with run-length encoding.

Consider each adjacent pair of elements `[a, b] = [nums[2*i], nums[2*i+1]]` (with `i >= 0`). For each such pair, there are `a` elements with value `b` in the decompressed list.

Return the decompressed list.

Example

## Solution

Actually, the description of this problem would be confusing, but the main idea behind that would be how to get `a, b`. Frist, we have to calculate the elements we have by sum of a and using b to fill the arr.

## [Medium] 1314. Matrix Block Sum

Given a `m * n` matrix `mat` and an integer `K`, return a matrix `answer` where each `answer[i][j]` is the sum of all elements `mat[r][c]` for `i - K <= r <= i + K, j - K <= c <= j + K`, and `(r, c)` is a valid position in the matrix.

Example

### Solution

We have to calculate the prefix sum of 2d array. Be careful of index.

## [Medium] 1315. Sum of Nodes with Even-Valued Grandparent

Given a binary tree, return the sum of values of nodes with even-valued grandparent. (A grandparent of a node is the parent of its parent, if it exists.)

If there are no nodes with an even-valued grandparent, return `0`.

Example

### Solution

We have to iterate each node and when it backs to root node, we just need to verify `root.left` and `root.right` .

## [Hard] 1316. Distinct Echo Substrings

Rank: 898 / 3489. Solve 3/4 in 33 min.