Skip to content

Commit 0509ac6

Browse files
solves convert integer to the sum of two no zero integers
1 parent f13fd31 commit 0509ac6

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -337,8 +337,8 @@
337337
| 1299 | [Replace Elements With Greatest Element on Right Side](https://leetcode.com/problems/replace-elements-with-greatest-element-on-right-side) | [![Java](assets/java.png)](src/ReplaceElementWithGreatestElementOnRightSide.java) [![Python](assets/python.png)](python/replace_element_with_greatest_element_on_right_hand_side.py) | |
338338
| 1304 | [Find N Unique Integers Sum Up To Zero](https://leetcode.com/problems/find-n-unique-integers-sum-up-to-zero) | [![Java](assets/java.png)](src/FindNUniqueIntegersSumUpToZero.java) | |
339339
| 1309 | [Decrypt String From Alphabet To Integer Mapping](https://leetcode.com/problems/decrypt-string-from-alphabet-to-integer-mapping) | [![Java](assets/java.png)](src/DecryptStringFromAlphabetToIntegerMapping.java) | |
340-
| 1313 | [Decompress Run-Length Encoded Strings](https://leetcode.com/problems/decompress-run-length-encoded-list) | [![Java](assets/java.png)](src/DecompressRunLengthEncodedList.java) | |
341-
| 1317 | [Convert Integer to Sum Of Two Non-Zero Integers](https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers) | | |
340+
| 1313 | [Decompress Run-Length Encoded Strings](https://leetcode.com/problems/decompress-run-length-encoded-list) | [![Java](assets/java.png)](src/DecompressRunLengthEncodedList.java) | |
341+
| 1317 | [Convert Integer to Sum Of Two Non-Zero Integers](https://leetcode.com/problems/convert-integer-to-the-sum-of-two-no-zero-integers) | [![Java](assets/java.png)](src/ConvertIntegerToTheSumOfTwoNoZeroIntegers.java) | |
342342
| 1323 | [Maximum 69 Number](https://leetcode.com/problems/maximum-69-number) | | |
343343
| 1331 | [Rank Transform of An Array](https://leetcode.com/problems/rank-transform-of-an-array) | | |
344344
| 1332 | [Remove Palindromic Subsequences](https://leetcode.com/problems/remove-palindromic-subsequences) | | |
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
public class ConvertIntegerToTheSumOfTwoNoZeroIntegers {
2+
public int[] getNoZeroIntegers(int n) {
3+
for (int i = 1 ; i <= n / 2 ; i++) {
4+
if (isNonZeroInteger(i) && isNonZeroInteger(n - i)) {
5+
return new int[] {i, n - i};
6+
}
7+
}
8+
return new int[0];
9+
}
10+
11+
private boolean isNonZeroInteger(int n) {
12+
while (n > 0) {
13+
if (n % 10 == 0) return false;
14+
n /= 10;
15+
}
16+
return true;
17+
}
18+
}

0 commit comments

Comments
 (0)