Skip to content

macOS Application. A string S is called a square if there is some string T such that S = T + T. For example, the strings "aabaab" and "xxxx" are squares, but "a", "aabb" and "aabbaa" are not.  You are given a String s. You want to change s into a square. You may do the following operations:  Insert a new character anywhere into the string (incl…

EgzonArifi/SquareMac

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

SquareMac

macOS Application.

A string S is called a square if there is some string T such that S = T + T. For example,

the strings "aabaab" and "xxxx" are squares, but "a", "aabb" and "aabbaa" are not. 

You are given a String s. You want to change s into a square. You may do the following operations:

 Insert a new character anywhere into the string (including its beginning and end).

 Remove a single character.

 Replace a single character by another character.

Please compute and return the smallest number of operations needed to change the given s into a square.

Note that this is always possible: for example, you can remove all characters (one at a time).

Definition

Class: RepeatString

Method: minimalModify

Parameters: String

Returns: int

About

macOS Application. A string S is called a square if there is some string T such that S = T + T. For example, the strings "aabaab" and "xxxx" are squares, but "a", "aabb" and "aabbaa" are not.  You are given a String s. You want to change s into a square. You may do the following operations:  Insert a new character anywhere into the string (incl…

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published