Algorithms/- LeetCode
-
LeetCode - Same Tree [Java]Algorithms/- LeetCode 2022. 2. 8. 22:39
문제 링크 : Same Tree Same Tree - 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 정답(Solution) /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { this.val = val; } * TreeNode(int val, Tr..
-
LeetCode - Binary Tree Inorder Traversal [Java]Algorithms/- LeetCode 2022. 2. 7. 22:56
문제 링크 : Binary Tree Inorder Traversal Binary Tree Inorder Traversal - 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 정답(Solution) Stack 풀이 /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(in..
-
LeetCode - 21. Merge Two Sorted Lists [Java], [Kotlin]Algorithms/- LeetCode 2022. 2. 5. 22:33
문제 링크 : 21. Merge Two Sorted Lists Merge Two Sorted Lists - 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 # Java 정답(Solution) /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode() {} * ListNode(int val) { this.val = val; } * L..
-
LeetCode - Valid Parentheses [Java]Algorithms/- LeetCode 2022. 1. 31. 03:03
문제 링크 : Valid Parentheses Valid Parentheses - 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 정답(Solution) import java.util.*; class Solution { public boolean isValid(String s) { /* (){}[] 열리고 같은걸로 닫혀야한다. 올바른 순서로 닫혀야한다. */ //Stack Stack st = new Stack(); Map map = new HashMap(); ma..
-
LeetCode - longest common prefix [Java]Algorithms/- LeetCode 2022. 1. 31. 01:56
문제 링크 : longest common prefix Longest Common Prefix - 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 정답(Solution) class Solution { public String longestCommonPrefix(String[] strs) { /* 공통 prefix를 리턴 없으면 "" */ if(strs.length == 1){ return strs[0]; } for(String str:strs){ if("".equa..
-
LeetCode - Roman to Integer [Java}Algorithms/- LeetCode 2022. 1. 31. 01:44
문제 링크 : Roman to Integer Roman to Integer - 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 정답(Solution) import java.util.*; class Solution { public int romanToInt(String s) { /* String arr 로 만들고 하나씩 빼면서 이후에 VX LC DM 이 오는지 체크하면서 교체 IV, IX, XL , XC, CD, CM */ Map romanMap = new Hash..
-
LeetCode - Palindrome Number [Java]Algorithms/- LeetCode 2022. 1. 31. 00:15
문제 링크 : Palindrome Number Palindrome 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 정답(Solution) class Solution { public boolean isPalindrome(int x) { //음수 if(x < 0){ return false; } //0 if(x == 0){ return true; } String xStr = String.valueOf(x); int xLength = xStr.length..
-
LeetCode - path sum [Java]Algorithms/- LeetCode 2022. 1. 30. 21:02
문제 링크 : path sum Path Sum - 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 정답(Solution) /** * Definition for a binary tree node. * public class TreeNode { * int val; * TreeNode left; * TreeNode right; * TreeNode() {} * TreeNode(int val) { this.val = val; } * TreeNode(int val, Tree..