Problem Statement
This problem has a non-standard time limit: 8 seconds.
You are given a
An ordered triple (i,j,k) is called a 737-triple if and only if:
- i, j, k are valid indices into S
- i < j < k
- S[i] = '7', S[j] = '3', and S[k] = '7'.
Definition
- Class:
- Make737Easy
- Method:
- count
- Parameters:
- String
- Returns:
- int
- Method signature:
- int count(String S)
- (be sure your method is public)
Constraints
- S will contain between 1 and 373 characters, inclusive.
- Each character of S will be either '3' or '7'.
Examples
"737"
Returns: 1
The only 737-triple in this string corresponds to the zero-based indices (0,1,2).
"777333"
Returns: 0
As we must have i < j < k, this string does not contain any 737-triples.
"773377"
Returns: 8
"73737"
Returns: 4
"3"
Returns: 0
"7"
Returns: 0
"33"
Returns: 0
"37"
Returns: 0
"73"
Returns: 0
"77"
Returns: 0
"3333"
Returns: 0
"3337"
Returns: 0
"3373"
Returns: 0
"3377"
Returns: 0
"3733"
Returns: 0
"3737"
Returns: 1
"3773"
Returns: 0
"3777"
Returns: 0
"7333"
Returns: 0
"7337"
Returns: 2
"7373"
Returns: 1
"7377"
Returns: 2
"7733"
Returns: 0
"7737"
Returns: 2
"7773"
Returns: 0
"7777"
Returns: 0
"3733333377333773777333373737777333733333337337777773377337737773773737337377737773777333733737337373377733337773333337377737373737773377773733773737737373337733737737373773733773377377337737377373737337333737373373377777777737733373777733733377377373777337733773777777733773373377377333773777733377773373337337733373733377373333773373737737773337737333333333773733373377773"
Returns: 979236
"7777377773733377377773733777733333333333337737777337773733373337337373773737333777377373333777373337333333737777777773337333777773333337377377337377733373777333773733337377337733333373377333737377373333773777373773377733737373337737737733333773733377333333377333733333773377737737333373737737733333337777377777733773773737737377733777777377377337333733377377777373373333373"
Returns: 1096642
"7733373737773773373777333333333373733733377333777377377373337373377337337337377377737777773373377337777737737337773737777373377333733737773373773733333777373773733373777777733337337377777733733333337373777373773737733777737337373733377777733337337373773377333333337337733737737777377773773373773777373337337333333333773777373773737377773733377337373373773337373737777733373"
Returns: 1046484
"7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333337777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777"
Returns: 1922000
"7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777"
Returns: 0
"3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333"
Returns: 0
"3333777777"
Returns: 0