← 返回 optiver 的题目列表Count the Occurrences of 'OPTIVER' in a Grid
类型:online_judge
Given a two-dimensional character matrix, create a function that identifies how many times the sequence "OPTIVER" appears. Matches can be found in straight lines either horizontally or vertically, in standard or reverse order.
Input Example:
["OPTCrrRO",
"ANROHLOp",
"UIEJHAQT",
"JOVTIVEI",
"HDIRdWWV",
"OPTIVERe",
"HNPREEEr",
"POOMLKR"]
Output: Return an integer representing the number of occurrences of "OPTIVER" found in the matrix.
Constraints:
The example input is a character matrix of height n and width m.
The sequence can be found in either direction along rows or columns.
Example
Input
"OPTCrrRO,ANROHLOp,UIEJHAQT,JOVTIVEI,HDIRdWWV,OPTIVERe,HNPREEEr,POOMLKR"