Statistics

Problem Statement for "SquareFreeString"

Problem Statement

We say that a string S is a square if it has the form TT, where T is some non-empty string. In other words, a square is a string that is a concatenation of two copies of the same non-empty string. For example, the strings "aa", "bbbb", and "beriberi" are squares.

A string is called square-free if none of its substrings is a square. For example, the string "abca" is square-free. (The substrings of this string are the strings "a", "b", "c", "a", "ab", "bc", "ca", "abc", "bca", and "abca". None of these strings is a square.)

You are given a String s. Return "square-free" if s is square-free. Otherwise, return "not square-free". Note that the return value is case-sensitive.

Definition

Class:
SquareFreeString
Method:
isSquareFree
Parameters:
String
Returns:
String
Method signature:
String isSquareFree(String s)
(be sure your method is public)

Constraints

  • s will consist only of lowercase English letters ('a'-'z').
  • The length of s will be between 1 and 50, inclusive.

Examples

  1. "w"

    Returns: "square-free"

  2. "cb"

    Returns: "square-free"

  3. "qok"

    Returns: "square-free"

  4. "aegi"

    Returns: "square-free"

  5. "oqquy"

    Returns: "not square-free"

  6. "ulhpnm"

    Returns: "square-free"

  7. "hncmexsslh"

    Returns: "not square-free"

  8. "psdurqrqdvmqgwplcktqejbhngvkjnrldskaxclvnblz"

    Returns: "not square-free"

  9. "wobervhvvkihcuyjtmqhaaigvahheoqleromusrartldojsjvy"

    Returns: "not square-free"

  10. "fcliblymyqckxvieotjotiqwtyznhvuhbaixwqnsytx"

    Returns: "square-free"

  11. "wobervhvkihcuyjtmqhaigvaheoqleromusrartldojsjvynfs"

    Returns: "square-free"

  12. "aydyamrbnauhftmphyroyqg"

    Returns: "square-free"

  13. "hncmexslhs"

    Returns: "square-free"

  14. "ijvxljt"

    Returns: "square-free"

  15. "qok"

    Returns: "square-free"

  16. "sijcwpcfrnlaqwdjftpxzrbtzil"

    Returns: "square-free"

  17. "cwlqeyjcukhsmumtesyoqjisfxqfgwjhx"

    Returns: "square-free"

  18. "rajcqwqnqmshmerpvjyfepxwpxyldzpzhctqjnstxyfmlhiyt"

    Returns: "square-free"

  19. "vmluxpwzhga"

    Returns: "square-free"

  20. "hncmexsxss"

    Returns: "not square-free"

  21. "rtcjbjlbtjrtcjbjlbtj"

    Returns: "not square-free"

  22. "wobervhvkihcuyjtmqhaigvaheoqleromusrartldoosjvynfs"

    Returns: "not square-free"

  23. "xiwpcfsmzenbvpdfpnduqienbvpdfpnduqiwngqb"

    Returns: "not square-free"

  24. "cwlqeyjcukhsmumtelqeyjcukhsmumtex"

    Returns: "not square-free"

  25. "qoo"

    Returns: "not square-free"

  26. "xtejpsfqyiplmyzuotbymtkcmuotbymtkcmrufgsyxmnqmc"

    Returns: "not square-free"

  27. "fcliblymyqckxvieotjotiqwtyznhtyznhixwqnsytx"

    Returns: "not square-free"

  28. "iraqgobfiaqgobfirhjcigigym"

    Returns: "not square-free"

  29. "porbdorbduvtu"

    Returns: "not square-free"

  30. "bobo"

    Returns: "not square-free"

    "bobo" = T + T, where T = "bo", so it is not square-free.

  31. "apple"

    Returns: "not square-free"

    Substring "pp" is a square.

  32. "pen"

    Returns: "square-free"

    "pen" does not contain any substrings that are squares.

  33. "aydyamrbnauhftmphyrooyq"

    Returns: "not square-free"

  34. "qwertyuiopasdfghjklzxcvbnm"

    Returns: "square-free"

  35. "abb"

    Returns: "not square-free"

  36. "a"

    Returns: "square-free"

  37. "abca"

    Returns: "square-free"

  38. "ssa"

    Returns: "not square-free"

  39. "bobk"

    Returns: "square-free"

  40. "abcdeezyok"

    Returns: "not square-free"

  41. "xdyrthsyu"

    Returns: "square-free"

  42. "acba"

    Returns: "square-free"

  43. "abcabc"

    Returns: "not square-free"

  44. "bab"

    Returns: "square-free"

  45. "abc"

    Returns: "square-free"

  46. "abcdd"

    Returns: "not square-free"

  47. "aa"

    Returns: "not square-free"

  48. "bkmbod"

    Returns: "square-free"

  49. "abcadc"

    Returns: "square-free"

  50. "abcdefafagheih"

    Returns: "not square-free"

  51. "abcdab"

    Returns: "square-free"

  52. "bolo"

    Returns: "square-free"

  53. "aaa"

    Returns: "not square-free"

  54. "dfidhrgneijrwsjackjackjierkf"

    Returns: "not square-free"

  55. "aba"

    Returns: "square-free"

  56. "asdfghjklqwertyuiopzxcvbnvcc"

    Returns: "not square-free"


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: