[LeetCode] 100. Same Tree
·
코딩테스트
leetcode.com/explore/learn/card/recursion-ii/503/recursion-to-iteration/2894/ Explore - LeetCode LeetCode Explore is the best place for everyone to start practicing and learning on LeetCode. No matter if you are a beginner or a master, there are always new topics waiting for you to explore. leetcode.com 첫 if문은 생각해냈고, 두번째 if문은 따로 적어줘야 하는걸 생각 못했다. 만약 첫 if 문 뒤에 else로 return false;를 하면 메서드가 끝나버리는 데 ..
[LeetCode] 509. Fibonacci Number (JAVA)
·
코딩테스트
leetcode.com/problems/fibonacci-number/ Fibonacci Number - 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 일반적인 재귀함수 풀이 (= 내 풀이) public int fib(int n) { int result = 0; //1. if문으로 했을 때 if(n==0){ result=0; }else if(n==1){ result=1; }else{ result=fib(n-1)+fib(n-2); } //2. switch문 swi..