Statistics

Problem Statement for "DoubleString"

Problem Statement

A string is called a square if it can be created by concatenating two copies of the same string. For example, "CANCAN" is a square because it consists of two copies of the string "CAN". Other squares include "AA", "ZZZZ", and "BERIBERI". The strings "AAAAA" and "HAHAHA" are not squares.

You are given a String S. Return "square" (quotes for clarity) if there is a string T such that S = T + T. Otherwise, return "not square". Note that the return value is case-sensitive.

Definition

Class:
DoubleString
Method:
check
Parameters:
String
Returns:
String
Method signature:
String check(String S)
(be sure your method is public)

Constraints

  • The length of S will be between 1 and 50, inclusive.
  • Each character in S will be an uppercase letter ('A'-'Z').

Examples

  1. "MAZAIMAZAI"

    Returns: "square"

    If T is "MAZAI", T+T will be "MAZAIMAZAI".

  2. "MAMAZAIZAI"

    Returns: "not square"

    In this case, there is no string T for which T+T will be S.

  3. "IOI"

    Returns: "not square"

    The length of S is odd, so it's impossible to make S by concatenating the same string twice.

  4. "AA"

    Returns: "square"

    T will be "A".

  5. "ABCCBA"

    Returns: "not square"

  6. "Y"

    Returns: "not square"

  7. "RFKQYUQFRFKQYUQF"

    Returns: "square"

  8. "KXYQVNRTYFKXYQVNRTYS"

    Returns: "not square"

  9. "RMZLYGFVEURMZLYGFVEU"

    Returns: "square"

  10. "QFPDBHLQDQERCRWDNXQFPDBHLQDQRRCRWDNX"

    Returns: "not square"

  11. "QQEKLAITGDPHCSPIJTHQQEKLAITGDPHCSPIJTH"

    Returns: "square"

  12. "SLYFVLADZPBFUDKKSFYFVLADZPBFUDKK"

    Returns: "not square"

  13. "QAOZMIXRQAOZMIXR"

    Returns: "square"

  14. "IFEFFECLHBVFUKBYEWFQOJIFEFFECLHBVFUKBYEQFQOJ"

    Returns: "not square"

  15. "OSILEEOSILEE"

    Returns: "square"

  16. "TXWJLKNGBQQMTXQCQPTXWJLKNGBQQMBXQCQP"

    Returns: "not square"

  17. "HQRQDWFCAYSSYOQCJOMWUFBDHQRQDWFCAYSSYOQCJOMWUFBD"

    Returns: "square"

  18. "XUZZHIFTAKCXUDZHIFTAKC"

    Returns: "not square"

  19. "SS"

    Returns: "square"

  20. "HLOETSWCRFHPXPRBSSBLOETSWCRFHPXPRBSS"

    Returns: "not square"

  21. "XDFXDF"

    Returns: "square"

  22. "LEBXWBCROAYAXZFBJBKLEBXWBCTOAYAXZFBJBK"

    Returns: "not square"

  23. "RIMQPZWRIMQPZW"

    Returns: "square"

  24. "SHLPWHTAZHBUXHSHLPJHTAZHBUXH"

    Returns: "not square"

  25. "LPTOYEZIWKMGSLPTOYEZIWKMGS"

    Returns: "square"

  26. "VQZGIVQZGD"

    Returns: "not square"

  27. "AAAAAAAAAA"

    Returns: "square"

  28. "RFKQYUQF"

    Returns: "not square"

  29. "KXYQVNRTYS"

    Returns: "not square"

  30. "RZRM"

    Returns: "not square"

  31. "LYGFVEULQFPDBHLQDQRRCRWDNXEUOQQEKL"

    Returns: "not square"

  32. "ITGDPHCSPIJTHBSFYFVLADZ"

    Returns: "not square"

  33. "BFUDKKLRWQAOZMIXRP"

    Returns: "not square"

  34. "FEFFECLHBVFUKBYEQFQOJWTWOSILE"

    Returns: "not square"

  35. "ZTX"

    Returns: "not square"

  36. "JLKNGBQQMBXQC"

    Returns: "not square"

  37. "PTKHHQRQDWFCAYSSYOQCJOMWUFBDFXUDZHIFTAKCZVHSYBLOE"

    Returns: "not square"

  38. "JSJ"

    Returns: "not square"

  39. "BBHHH"

    Returns: "not square"

  40. "AAAAA"

    Returns: "not square"

  41. "AB"

    Returns: "not square"

  42. "ABCABC"

    Returns: "square"

  43. "AAA"

    Returns: "not square"


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: