Merge Strings Alternately
·
알고리즘
문제는 아래와 같다. 대충 단어를 교차하여 조합해 보라는 말인 것 같다~~ 내가 푼 코드 class Solution { public String mergeAlternately(String word1, String word2) { int w1 = word1.length(); int w2 = word2.length(); StringBuilder sb = new StringBuilder(); int i = 0; while (i < w1 || i < w2) { if (i < w1) { sb.append(word1.charAt(i)); } if (i < w2) { sb.append(word2.charAt(i)); } i++; } return sb.toString(); } } 한줄씩 코드를 해석해 보자면 주어진 w..
github와 leetcode 연동을 이용한 알고리즘 포트폴리오 만들기
·
git
알고리즘 문제를 풀 때마다 github에 자동으로 커밋해 주고 내 리파지토리에 업로드되어 포트폴리오처럼 사용할 수 있는 방법에 대해 소개하려고 한다. 우선 github에 가입이 되어 있다는 가정하에 진행된다! [leetcode 회원가입] LeetCode - The World's Leading Online Programming Learning Platform 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 문제는 상단의 Problems에 있다. leetcode는 백준이나 프로그래머..
해니01_15
'알고리즘' 태그의 글 목록