Statistics

Problem Statement for "Make737Easy"

Problem Statement

This problem has a non-standard time limit: 8 seconds.

You are given a String S. Each character of S is either '3' or '7'. Compute and return the number of 737-triples in this string.

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

  1. "737"

    Returns: 1

    The only 737-triple in this string corresponds to the zero-based indices (0,1,2).

  2. "777333"

    Returns: 0

    As we must have i < j < k, this string does not contain any 737-triples.

  3. "773377"

    Returns: 8

  4. "73737"

    Returns: 4

  5. "3"

    Returns: 0

  6. "7"

    Returns: 0

  7. "33"

    Returns: 0

  8. "37"

    Returns: 0

  9. "73"

    Returns: 0

  10. "77"

    Returns: 0

  11. "3333"

    Returns: 0

  12. "3337"

    Returns: 0

  13. "3373"

    Returns: 0

  14. "3377"

    Returns: 0

  15. "3733"

    Returns: 0

  16. "3737"

    Returns: 1

  17. "3773"

    Returns: 0

  18. "3777"

    Returns: 0

  19. "7333"

    Returns: 0

  20. "7337"

    Returns: 2

  21. "7373"

    Returns: 1

  22. "7377"

    Returns: 2

  23. "7733"

    Returns: 0

  24. "7737"

    Returns: 2

  25. "7773"

    Returns: 0

  26. "7777"

    Returns: 0

  27. "3733333377333773777333373737777333733333337337777773377337737773773737337377737773777333733737337373377733337773333337377737373737773377773733773737737373337733737737373773733773377377337737377373737337333737373373377777777737733373777733733377377373777337733773777777733773373377377333773777733377773373337337733373733377373333773373737737773337737333333333773733373377773"

    Returns: 979236

  28. "7777377773733377377773733777733333333333337737777337773733373337337373773737333777377373333777373337333333737777777773337333777773333337377377337377733373777333773733337377337733333373377333737377373333773777373773377733737373337737737733333773733377333333377333733333773377737737333373737737733333337777377777733773773737737377733777777377377337333733377377777373373333373"

    Returns: 1096642

  29. "7733373737773773373777333333333373733733377333777377377373337373377337337337377377737777773373377337777737737337773737777373377333733737773373773733333777373773733373777777733337337377777733733333337373777373773737733777737337373733377777733337337373773377333333337337733737737777377773773373773777373337337333333333773777373773737377773733377337373373773337373737777733373"

    Returns: 1046484

  30. "7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333337777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777"

    Returns: 1922000

  31. "7777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777777"

    Returns: 0

  32. "3333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333"

    Returns: 0

  33. "3333777777"

    Returns: 0


This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2024, TopCoder, Inc. All rights reserved.
This problem was used for: