분류 전체보기
-
392. Is Subsequence javaLeetCode_Study_Plan/LeetCode 75 2022. 10. 4. 23:16
https://leetcode.com/problems/is-subsequence/ class Solution { public boolean isSubsequence(String s, String t) { String[] s_lt = s.split(""); String[] t_lt = t.split(""); if (s.length() == 0) return true; int index = 0; for(String each_t: t_lt){ if (index == s_lt.length) return true; if(s_lt[index].equals(each_t)){ index++; } } if (index == s_lt.length) return true; return false; } }
-
int와 Integer 차이Backend/Java 2022. 10. 4. 20:59
일단 int는변수의 타입으로 primitive type(기본형) 중 하나이다. primitive type에는 위와 같은 종류들이 있다. Integer은Wrapper class의 하나이다. Wrapper class는 기본형을 객체로 다루기 위해서 사용하는 클래스이다. 모든 기본 형은 Wrapper class를 생성할 수 있고 종류는 아래와 같다. 기본형을 언제 객체로 다룰 때 주로 쓸까를 생각해보면 1. 기본형 값이 아닌 객체로 저장해야할 때 2. 객체 간 비교가 필요할 때 3. 매개변수로 객체를 필요로 할 때 가 있을 수 있다. 또한 나의 경우 현업에서 언제 질문을 받았냐면, Repository에서 받아오는 데이터가 숫자의 형태였고 아무생각없이 Integer를 선언해서 받아왔다. 사수님이 왜 int가 아..
-
JPA Repository 호출 시 NullPointerException, Cannot invoke "repository.메소드명()" because "this.repository" is null 해결 방법Backend/Springboot 2022. 10. 4. 17:28
생성자가 주입되지 않아 생긴 문제 1. 접근자를 final로 선언해야 롬복이 작동하므로 final로 repository를 선언 2. 해당 클래스 위에 lombok의 @RequiredArgsConstructor를 attach해준다. 사용 예시 @Service @RequiredArgsConstructor public class MyInfoService { final UserRepository userRepository; final EssayRepository essayRepository; public MyInfoDto.Response getMyInfo(String user_id) { User myInfo = userRepository.findByUserId(user_id); List essay = essay..
-
having vs where 차이점Backend/DB 2022. 10. 4. 16:44
SQL 문제를 풀다가 where절로 행 필터링 했을 때는 틀렸지만, having절로 풀었을 때 정답이 나와서 다음의 차이를 정리해보고자 한다. 문제 : https://lulu-developmentlog.tistory.com/85?category=1070019 1084. Sales Analysis III mysql https://leetcode.com/problems/sales-analysis-iii/ Sales Analysis III - LeetCode Level up your coding skills and quickly land a job. This is the best place to expand your knowledge and get prepared f.. lulu-developmentlog.t..
-
1084. Sales Analysis III mysqlLeetCode_Study_Plan/SQL 2022. 10. 4. 11:38
https://leetcode.com/problems/sales-analysis-iii/ Sales Analysis III - 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 틀린 시도 select p.product_id, p.product_name from (select product_id, sale_date from sales where sale_date between '2019-01-01' and '2019-03-31') tb join product p on..
-
1587. Bank Account Summary II mysqlLeetCode_Study_Plan/SQL 2022. 10. 4. 11:17
https://leetcode.com/problems/bank-account-summary-ii/?envType=study-plan&id=sql-i Bank Account Summary II - 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 select u.name, tb.sum as balance from (select account, sum(amount) as sum from Transactions group by account having sum(amoun..
-
1050. Actors and Directors Who Cooperated At Least Three Times mysqlLeetCode_Study_Plan/SQL 2022. 10. 4. 11:08
https://leetcode.com/problems/actors-and-directors-who-cooperated-at-least-three-times/?envType=study-plan&id=sql-i Actors and Directors Who Cooperated At Least Three Times - 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 select actor_id, director_id from actordirector group by 1,..