Algorithm

    Climbing Stairs를 recursive 아닌 방법으로 풀어보기

    전에 Recursive로 풀었던 포스팅 2021.04.08 - [개발 공부/코딩 테스트] - [LeetCode] - Climbing Stairs [LeetCode] - Climbing Stairs Memoization문제 sudo code n개의 계단을 올라간다 한걸음에 1 또는 2개 계단을 올라갈 수 있다 1

    [LeetCode] Longest common prefix

    단어가 들어있는 String 배열에서 가장 긴 공통된 접두어를 구하라. sudo code 가장 긴 단어와 가장 짧은 단어를 고르고 가장 짧은 단어의 길이만큼 긴 단어의 앞에서 부터 비교 차감하면서 비교 같지 않다면 "" 리턴 1차 시도있는 String 배열에서 가장 긴 공통된 접두어를 구하라. sudo code 가장 긴 단어와 가장 짧은 단어를 고르고 가장 짧은 단어의 길이만큼 긴 단어의 앞에서 부터 비교 차감하면서 비교 같지 않다면 "" 리턴 1차 시도 class Solution { public String getShortestWord(String[] strs) { if (strs == null || strs.length < 1) { return ""; } String shortestWord = str..

    [LeetCode] - Reverse Linked List

    Single LinkedList 순서를 역순으로 /* 일단 순회부터 while(head.next != null) { System.out.println(head.val); head = head.next; 1 = 2, 2 = 3, 3 = 4, 4 = 5, 5.next = null } */ // return head; /* public class Main { public static void main(String[] args) { ListNode head = new ListNode(5,null); head = new ListNode(4,head); head = new ListNode(3,head); head = new ListNode(2,head); head = new ListNode(1,head); List..

    [LeetCode] - Climbing Stairs

    Memoization문제 sudo code n개의 계단을 올라간다 한걸음에 1 또는 2개 계단을 올라갈 수 있다 1

    [프로그래머스] - [1차] 추석 트래픽

    sudo Code lines는 오름차순으로 정렬되어 있음 첫번째 값부터 시작하나 마지막부터 시작하나 마지막 값이 끝나는 시간을 의미하지는 않음 -> lines[5] 01.000 3 -> 04 lines[6] 02.000 1 -> 03 일단 unix TimeStamp값 구함 구한 값에 during값을 더해서 각 시간의 start와 end를 구함 start시간부터 초로 구별하여 각각 cnt를 더해줌 여기서 가장 높은 cnt를 반환 unixTimeStamp convert import java.util.*; import java.text.SimpleDateFormat; class Solution { public int solution(String[] lines) { int answer = 0; String fi..

    [프로그래머스] - 타겟 넘버

    주어진 int[] numbers로 int target 값을 만들수 있는 가짓수를 return 하라 sudo code /* sudo code dfs bfs를 잘 모르기 때문에 완전 탐색으로 접근 numbers[0] -> + or - 2^20 -> 1,048,576 백만이면 많이 안 걸릴듯 가능 1.모든 조합식 때려넣기 2. target과 비교 3. 비교시 동일하다면 answer++ 4. return answer -> 1번 어떻게? 모든 조합식은 2^length만큼 존재 ex [1,1,1] => temp = number[0]; array.add(temp); 1 array.add(-temp); -1 temp = number[1]; arr.get(i-1) + array.add -> 1, -1 1 1 2 -1 3..