You are given a string named digits made of digits '0' and/or '2'. It represents a positive integer. Remove zero or more digits from it, so that each remaining digit occurs an even number of times and the value of the resulting integer is as large as possible.
Write a function:
class Solution {
public String solution(String digits);
}
that, given a string named digits of length N, representing the integer, returns a string representing the largest obtainable integer after performing the removals.
Write an efficient algorithm for the following assumptions:
Hard