Skip to content

Commit

Permalink
[LEET-3280] add 3280
Browse files Browse the repository at this point in the history
  • Loading branch information
fishercoder1534 committed Oct 28, 2024
1 parent d75c98e commit d464578
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions paginated_contents/algorithms/4th_thousand/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
| 3300 | [Minimum Element After Replacement With Digit Sum](https://leetcode.com/problems/minimum-element-after-replacement-with-digit-sum/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3300java) | | Easy |
| 3289 | [The Two Sneaky Numbers of Digitville](https://leetcode.com/problems/the-two-sneaky-numbers-of-digitville/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3289.java) | | Easy |
| 3285 | [Find Indices of Stable Mountains](https://leetcode.com/problems/find-indices-of-stable-mountains/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3285.java) | | Easy |
| 3280 | [Convert Date to Binary](https://leetcode.com/problems/convert-date-to-binary/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3280.java) | | Easy |
| 3270 | [Find the Key of the Numbers](https://leetcode.com/problems/find-the-key-of-the-numbers/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3270.java) | | Easy |
| 3264 | [Final Array State After K Multiplication Operations I](https://leetcode.com/problems/final-array-state-after-k-multiplication-operations-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3264.java) | | Easy |
| 3263 | [Convert Doubly Linked List to Array I](https://leetcode.com/problems/convert-doubly-linked-list-to-array-i/) | [Java](https://github.com/fishercoder1534/Leetcode/blob/master/src/main/java/com/fishercoder/solutions/fourththousand/_3263.java) | | Easy |
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/com/fishercoder/solutions/fourththousand/_3280.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.fishercoder.solutions.fourththousand;

public class _3280 {
public static class Solution1 {
public String convertDateToBinary(String date) {
String[] parts = date.split("-");
StringBuilder sb = new StringBuilder();
for (String part : parts) {
sb.append(Integer.toBinaryString(Integer.parseInt(part)));
sb.append("-");
}
sb.setLength(sb.length() - 1);
return sb.toString();
}
}
}
21 changes: 21 additions & 0 deletions src/test/java/com/fishercoder/fourththousand/_3280Test.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.fishercoder.fourththousand;

import static org.junit.jupiter.api.Assertions.assertEquals;

import com.fishercoder.solutions.fourththousand._3280;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

public class _3280Test {
private _3280.Solution1 solution1;

@BeforeEach
public void setup() {
solution1 = new _3280.Solution1();
}

@Test
public void test1() {
assertEquals("100000100000-10-11101", solution1.convertDateToBinary("2080-02-29"));
}
}

0 comments on commit d464578

Please sign in to comment.