| | 1 | | // -------------------------------------------------------------------------------- |
| | 2 | | // Copyright (C) 2025 Eugene Eremeev (also known as Yevhenii Yeriemeieiv). |
| | 3 | | // All Rights Reserved. |
| | 4 | | // -------------------------------------------------------------------------------- |
| | 5 | | // This software is the confidential and proprietary information of Eugene Eremeev |
| | 6 | | // (also known as Yevhenii Yeriemeieiv) ("Confidential Information"). You shall not |
| | 7 | | // disclose such Confidential Information and shall use it only in accordance with |
| | 8 | | // the terms of the license agreement you entered into with Eugene Eremeev (also |
| | 9 | | // known as Yevhenii Yeriemeieiv). |
| | 10 | | // -------------------------------------------------------------------------------- |
| | 11 | |
|
| | 12 | | namespace LeetCode.Algorithms.UniqueThreeDigitEvenNumbers; |
| | 13 | |
|
| | 14 | | /// <inheritdoc /> |
| | 15 | | public class UniqueThreeDigitEvenNumbersBruteForce : IUniqueThreeDigitEvenNumbers |
| | 16 | | { |
| | 17 | | /// <summary> |
| | 18 | | /// Time complexity - O(n^3) |
| | 19 | | /// Space complexity - O(n^3) |
| | 20 | | /// </summary> |
| | 21 | | /// <param name="digits"></param> |
| | 22 | | /// <returns></returns> |
| | 23 | | public int TotalNumbers(int[] digits) |
| 4 | 24 | | { |
| 4 | 25 | | var numbersHashSet = new HashSet<int>(); |
| | 26 | |
|
| 34 | 27 | | for (var i = 0; i < digits.Length; i++) |
| 13 | 28 | | { |
| 112 | 29 | | for (var j = 0; j < digits.Length; j++) |
| 43 | 30 | | { |
| 376 | 31 | | for (var k = 0; k < digits.Length; k++) |
| 145 | 32 | | { |
| 145 | 33 | | if (i == j || i == k || j == k) |
| 103 | 34 | | { |
| 103 | 35 | | continue; |
| | 36 | | } |
| | 37 | |
|
| 42 | 38 | | if (digits[i] == 0 || digits[k] % 2 != 0) |
| 20 | 39 | | { |
| 20 | 40 | | continue; |
| | 41 | | } |
| | 42 | |
|
| 22 | 43 | | numbersHashSet.Add((digits[i] * 100) + (digits[j] * 10) + digits[k]); |
| 22 | 44 | | } |
| 43 | 45 | | } |
| 13 | 46 | | } |
| | 47 | |
|
| 4 | 48 | | return numbersHashSet.Count; |
| 4 | 49 | | } |
| | 50 | | } |