Question: Question #2 (10 Points): Using Stacks, write a java method that takes a string consisting of sequence of the letters U and D, where U

Question #2 (10 Points): Using Stacks, write a java method that takes a string consisting of sequence of the letters U and D, where U means UP or Increasing and D means DOWN or Deceasing and then returns the smallest number which consists of non-repeated digits formed based on the pattern described by the input string. Examples: 1) if the string is: "UUDDUDUD" the returned number will be: 125437698 2) if the string is: "UDUDUU" the returned number will be 1325467 3) if the string is "DDDDD" the returned number will be 654321 4) if the string is "UUUU" the returned number will be 12345 Question #2 (10 Points): Using Stacks, write a java method that takes a string consisting of sequence of the letters U and D, where U means UP or Increasing and D means DOWN or Deceasing and then returns the smallest number which consists of non-repeated digits formed based on the pattern described by the input string. Examples: 1) if the string is: "UUDDUDUD" the returned number will be: 125437698 2) if the string is: "UDUDUU" the returned number will be 1325467 3) if the string is "DDDDD" the returned number will be 654321 4) if the string is "UUUU" the returned number will be 12345
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
