All Downloads are FREE. Search and download functionalities are using the official Maven repository.

g3201_3300.s3280_convert_date_to_binary.Solution Maven / Gradle / Ivy

The newest version!
package g3201_3300.s3280_convert_date_to_binary;

// #Easy #String #Math #2024_09_09_Time_3_ms_(100.00%)_Space_42.4_MB_(50.00%)

public class Solution {
    private String helper(String str) {
        return Integer.toBinaryString(Integer.parseInt(str));
    }

    public String convertDateToBinary(String date) {
        StringBuilder sb = new StringBuilder();
        for (String str : date.split("-")) {
            sb.append(helper(str));
            sb.append("-");
        }
        sb.deleteCharAt(sb.length() - 1);
        return sb.toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy