본문 바로가기

반응형

Java/Java 알고리즘 LeetCode

(60)
[LeetCode- Ch.1 문자열] 4. 플러스 원 https://leetcode.com/problems/plus-one/submissions/ Plus One - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com import java.util.stream.Stream; class Solution { public int[] plusOne(int[] digits) { //비어 있지 않은 십진수 배열 주어지면 1증가 //배열의 마지막 숫자에 +1 //숫자 0제외 정수 앞에 0미포함 int n = digits.length..
[LeetCode- Ch.1 문자열] 3. 라이센스 키 포맷 (+ StringBuilder.insert(위치,문자)) https://leetcode.com/problems/license-key-formatting/submissions/ License Key Formatting - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com class Solution { public String licenseKeyFormatting(String s, int k) { //뒤에서부터 k개수만큼 자르고 사이에 '-' 문자 추가하기 //소문자일 경우 대문자로 변경 //1.ds //모든 '-'문자 제거..
[LeetCode- Ch.1 문자열] 2. 보석과 돌 (+ toCharArray) https://leetcode.com/problems/jewels-and-stones/submissions/ Jewels and Stones - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com class Solution { public int numJewelsInStones(String jewels, String stones) { //1.ds char[] jew_arr = jewels.toCharArray(); int count=0; //2.loop for(cha..
[LeetCode- Ch.1 문자열] 1. 고유한 이메일 (+ StringBuilder, toCharArray) https://leetcode.com/problems/unique-email-addresses/submissions/ Unique Email Addresses - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared for your next interview. leetcode.com import java.util.*; class Solution { public int numUniqueEmails(String[] emails) { int N=emails.length; Set set = new HashSet(); //2. Loop //: ..

반응형