3
As we know that we want unique numbers of 3 digits only that too only even. so first we4
gather the frequency of all the digits we have, then we iterate from 100 to 999 ( all possible 3 digits numbers, 100,102,104...5
all possible even 3 digit numbers). for ex we are iterating and we are6
at 104 so we will see that if we have digits7
1,0,4 in our database if yes then we can make this number from our8
available digits given to us.11
Time complexity : O(digits.length) // due to making of frequency map12
Space Complexity : O(1) //fixed map array space for digits 0 to 916
public int[] findEvenNumbers(int[] digits) {17
int[] map = new int[10]; // for freq of 0 to 9 (digits are fixed)19
for (int i = 0; i < digits.length; i++) { // make a frequency map of digits23
List<Integer> arr = new ArrayList<>();25
for (int i = 100; i <= 999; i = i + 2) { // will always runs from 100 to 99927
int[] freq = new int[10];28
while (num > 0) { // will always run 3 times34
boolean res = findans(freq, map);38
int[] ans = new int[arr.size()]; // logic for arraylist to array conversion39
for (int i = 0; i < arr.size(); i++) { // at max we can have all num from 100 to 998 only46
private boolean findans(int[] currentNum, int[] database) {48
for (int i = 0; i < 10; i++) { // it will always run for at max 10 times49
if (currentNum[i] > database[i]) return false;