ShareChat | SDE2 | DSA
Anonymous User
1186

You are given cell phone chargers and cell phones.
Each cell phone associates with same type of charger.
Example charger of type x connects with only cell phone having type x.
All the cell phones and chargers are placed in two horizontal lines respectively
Now we want to know the maximum chargers we can connect such that, chargers does not intersect any other connecting line.
Return the maximum number of charging lines we can draw in this way.
Input: A = [1,4,5], B = [1,2,4]
Output: 2
i ->
A 1 4 5
B 0 0 0 0
1 0 1 1
2 0 1 1
4 0 1 2

Explanation: We can draw 2 uncrossed lines
1 4 2
|
1 2 4
We cannot draw 3 uncrossed lines, because the line from A[1]=4 to B[2]=4 will intersect the line from A[2]=2 to B[1]=2.

Input: A = [1,4,2,5,7,8,5], B = [1,7,4,3,8,5]
Output: 4

You are given a board which contains different characters. It can have repeated characters too.
Also you are given a dictionary that contains few words.
Find all possible words that can be formed by a sequence of adjacent characters. And if present in dictionary, print that word.
Note: Also a word should not have multiple instances of same cell.
dictionary = { "SHARE", "CHAT", "MOJ", "SHARECHAT" };
board[][] = {{'S', 'C', 'E'},
{'H', 'H', 'R'},
{'A', 'T', 'A'}};
Output: SHARE
CHAT
SHARECHAT

Note: If anyone needs solution for the same, let me know in the comment section :)

Comments (3)