← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Given a 2-D grid of characters board and a list of strings words, return all words that are present in the grid. For a word to be present it must be possible to form the word with a path in the board with horizontally or vertically neighboring cells. The same cell may not be used more than once in a word.
m x n grid of characters where m and n are the number of rows and columns in the grid.board[i][j] is a single lowercase or uppercase letter.1 <= words.length <= 3 * 10^41 <= words[i].length <= 10words[i] are lowercase or uppercase letters.Input:
board = [ ['o','a','a','n'], ['e','t','a','e'], ['i','h','k','r'], ['i','f','l','v'] ] words = ["oath","pea","eat","rain"]
Output:
["eat","oath"]
Input:
board = [ ['a','b'], ['c','d'] ] words = ["abcb"]
Output:
[]
'a'-'z', 'A'-'Z').