Skip to content

Commit 8f6b5cc

Browse files
authored
Wordboggle.cpp
Question description added
1 parent 21bf312 commit 8f6b5cc

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

Data Structures/Graphs/WordBoggle.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,40 @@
1+
// Given a dictionary of distinct words and an M x N board where every cell has one character. Find all possible words from the dictionary that can be formed by a sequence of adjacent characters on the board. We can move to any of 8 adjacent characters, but a word should not have multiple instances of the same cell.
2+
// Example 1:
3+
4+
// Input:
5+
// N = 1
6+
// dictionary = {"CAT"}
7+
// R = 3, C = 3
8+
// board = {{C,A,P},{A,N,D},{T,I,E}}
9+
// Output:
10+
// CAT
11+
// Explanation:
12+
// C A P
13+
// A N D
14+
// T I E
15+
// Words we got is denoted using same color.
16+
// Example 2:
17+
18+
// Input:
19+
// N = 4
20+
// dictionary = {"GEEKS","FOR","QUIZ","GO"}
21+
// R = 3, C = 3
22+
// board = {{G,I,Z},{U,E,K},{Q,S,E}}
23+
// Output:
24+
// GEEKS QUIZ
25+
// Explanation:
26+
// G I Z
27+
// U E K
28+
// Q S E
29+
// Words we got is denoted using same color.
30+
31+
// Companies
32+
// Amazon Directi Facebook Google MakeMyTrip Microsoft Nvidia Yahoo
33+
34+
// Expected Time Complexity: O(NW + RC^2)
35+
// Expected Auxiliary Space: O(NW + RC)
36+
------------------------------------------------------------
37+
138
#include<bits/stdc++.h>
239
using namespace std;
340

0 commit comments

Comments
 (0)