DEV Community

arcade
arcade

Posted on

Weekly Coding Questions - W4

Here are this week's questions :)

1) Number of Zero-Filled Subarrays

For a string of length 'n', no. of substrings that can be formed is equal to n * (n+1)/2.

2) Design a Number Container System

Map data structure and try to understand how can we map index and number in an efficient way.

3) Equal Row and Column Pairs

Using map to store the rows and then traversing column wise to increment the count if the same column is present as a row in map.

4) Longest Word in Dictionary

Idea is to use try to store all the words in it. So, when we want to determine the max length word whose all prefix are present in the dictionary, we just check for every prefix of that whether its present in the trie or not.
Link to Solution

5) Top K Frequent Words

Priority queue and map implementation question nothing much.

6) Replace Words

Trie problem, search word prefix

7) Group Anagrams

Sorting of words and using map.

8) Implement Trie (Prefix Tree)

Trie implementation Link to solution

9) Reverse Linked List

Reversing the linked list using three pointers or using recursion.

10) Search Insert Position

Binary search problem

11) Add Two Numbers

Normal linked list implementation

12) Check if Matrix Is X-Matrix

Normal matrix question

Top comments (0)