POJO(Plain Old Java Object) 기반 개발 EJB는 프레임워크와 서버 환경에 의존적인 코드가 많았다 설정 파일 또한 난해했다 원래는 개발자가 비즈니스 로직에만 집중할 수 있도록 EJB가 로우 레벨 관리를 대신하게 할 목적이었다 그러나 EJB 코드는 EJB의 인터페이스와 클래스를 상속하는 방식으로 개발되었기 때문에 코드가 EJB 환경에 종속되고 추가로 상속이 되지 않아 객체지향적으로 개발을 하지 못하게 되는 부작용을 초래했다 Spring은 서비스 추상화를 통해 코드에서 프레임워크와 환경에 의존적인 부분을 제거했다 추상화로 로우 레벨의 기술 구현을 분리하고 독립적으로 접근할 수 있는 인터페이스를 제공한다 그 결과, POJO(Plain Old Java Object)로 비즈니스 로직을 개발할 ..
All
![](https://img1.daumcdn.net/thumb/R750x0/?scode=mtistory2&fname=https%3A%2F%2Fblog.kakaocdn.net%2Fdn%2Fl3a9X%2FbtsFsqD0KIv%2FKes6kHjDXxWRUv1h2gbPt0%2Fimg.jpg)
https://leetcode.com/problems/trapping-rain-water/description/ 의 풀이 중 스택 풀이가 잘 이해되지 않아서 정리한 내용을 공유합니다 막대를 하나씩 세운다고 생각했을 때 물을 저장할 수 있는 조건을 생각해 봅시다. 다음 막대로 마지막 막대보다 높이가 같거나 작은 막대가 오면 내리막길 모양이 되어서 물을 채울 수 없습니다. (5, 4, 3, 2, 1) 마지막 막대보다 높이가 높은 막대가 오면 물을 채울 수 있는데, 이 때 이전 막대 중에서 새 막대보다 높이가 낮은 막대 위에만 물을 채울 수 있습니다. 이 때 채울 수 있는 물의 양은 막대 하나와 새 막대의 거리 * min(왼쪽 막대, 오른쪽 막대) 높이 차 로 각 막대와 새 막대의 차이 때문에 담을 수 있는 ..
크롬에서 쓰이는 JS 엔진인 V8 엔진은 C++로 구현되어 있고, 깃허브에 소스가 공개되어 있습니다 JS integer array는 V8 내부에서는 C++ array인데, 중간에 빈 value가 많은 경우(sparse한 경우) hash table로 구현됩니다 그래서 sparse한 array는 성능이 더 나쁘다고 합니다 JS array를 선언할 때 V8 내부에서는 length를 element 개수보다 더 크게 잡은 배열을 선언합니다 (dynamic array) 그래서 일반적인 상황에서 push() 를 O(1) 시간에 수행할 수 있습니다 공간이 부족할 경우 크기를 늘리는 공식(growth factor) - 약 1.5배로 늘림 new_capacity = (old_capacity + 50%) + 16 실제 코드..
https://leetcode.com/problems/longest-palindromic-substring/ Longest Palindromic Substring - 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 핵심 아이디어 모든 문자에 대해 two pointer를 확장해 가며 s[left] === s[right] 를 비교한다 substring 길이가 홀수인 경우, 짝수인 경우 case로 나눠서 두 번 구한다 복잡도 시간 복잡도: O(n^2) string 모든..
https://leetcode.com/problems/group-anagrams/submissions/ Group Anagrams - 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 핵심 아이디어 순서가 다른 문자열은 정렬하면 같은 문자열이 된다 복잡도 시간 복잡도: O(N * KlogK) 문자열 N개 * K길이 문자열 정렬 KlogK 공간 복잡도: O(N) anagrams hash map (이차원처럼 보이지만, 전체 개수는 N개이다) 설명 "문자열 배열을 받아 ..
https://leetcode.com/problems/most-common-word/ Most Common Word - 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 핵심 아이디어 split() 에 정규표현식 /W+/ (not word, 1 or more) 를 사용하여 알파벳만 배열 나눌 수 있다 O(N)인 Array.includes() 보다는 O(1)인 Map.has()가 시간이 적게 걸린다 복잡도 N = 단어의 개수라면, 시간 복잡도: O(N) filter ..
https://leetcode.com/problems/reorder-data-in-log-files/ Reorder Data in Log Files - 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 핵심 아이디어 letterLogs, digitLogs 두 배열로 나눈 뒤 합친다 js string 비교는 String.localeCompare()로 할 수 있다 복잡도 시간 복잡도: O(N^2*logN) sort() NlogN * slice() N 공간 복잡도: O(..
https://leetcode.com/problems/reverse-string/ Reverse String - 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 핵심 아이디어 js에 Array.reverse() 가 있으니 그걸 쓰거나... left, right two pointer로 양쪽에서 반복하며 swap하면 배열이 뒤집어진다 js에서 swap할 때는 destructing asssignment [a,b] = [b,a] 를 활용할 수 있다 복잡도 시간 복잡도: ..