| ||In algebra, a presentation is a convenient way to describe a set. The presentation includes what the atomic elements of the set are, and what relations are used to simplify strings of atoms. These atoms are usually called generators. In this problem we will be looking at a set whose generators are x and y. You will be given a String expression consisting of x's and y's. The simplifying rules are:
Two strings A and B are equivalent if there is a string C such that A can be simplified into C and B can be simplified into C by applying the rules above 0 or more times. Return the shortest string equivalent to expression. If there are multiple possible solutions, return the one that comes first alphabetically.
- 1) Any occurrence of yyyyyy can be deleted from the string.
- 2) Any occurrence of xxxxxxxx can be deleted from the string.
- 3) Any occurrence of xy can be replaced by yyyyyx.
|Method signature:||String simplify(String expression)|
|(be sure your method is public)|
|-||expression will contain between 1 and 50 characters inclusive.|
|-||Each character in expression will be x or y.|
|Doesn't get much simpler.|
|Use the one that comes first alphabetically.|