Algorithms/- LeetCode
-
LeetCode - 392. Is Subsequence [Kotlin]Algorithms/- LeetCode 2022. 9. 10. 03:51
문제 링크 : https://leetcode.com/problems/is-subsequence/ Is Subsequence - 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 { fun isSubsequence(s: String, t: String): Boolean { var sIndex = 0 for(i in 0 until t.length){ if(sIndex < s.length && s[sIndex] == t[..
-
LeetCode - 205. Isomorphic Strings [Kotlin]Algorithms/- LeetCode 2022. 9. 7. 01:23
문제 링크 : 205. Isomorphic Strings Isomorphic Strings - 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 { fun isIsomorphic(s: String, t: String): Boolean { val sKeyMap = HashMap() val tKeyMap = HashMap() for(i in s.indices){ val sValue : Char? = sKeyMap[s[i..
-
LeetCode - 724. Find Pivot Index [Kotlin]Algorithms/- LeetCode 2022. 9. 5. 11:00
문제 링크 : https://leetcode.com/problems/find-pivot-index/ Find Pivot Index - 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 { fun pivotIndex(nums: IntArray): Int { val totalSum = nums.sum() var leftSum = 0 for(i in 0 until nums.size){ if(leftSum == (tota..
-
LeetCode - 1480. Running Sum of 1d Array [Kotlin]Algorithms/- LeetCode 2022. 8. 2. 10:30
문제 링크 : 1480. Running Sum of 1d Array Running Sum of 1d Array - 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 { fun runningSum(nums: IntArray): IntArray { for(i in 1 until nums.size){ nums[i] += nums[i-1] } return nums } }
-
LeetCode - Trim a Binary Search Tree [Java]Algorithms/- LeetCode 2022. 4. 16. 00:59
문제 링크 : Trim a Binary Search Tree Trim a Binary Search 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) class Solution { public TreeNode trimBST(TreeNode root, int low, int high) { if (root == null) return root; if (root.val > high) return trimBST(root.left, low,..
-
LeetCode - Binary Tree Postorder Traversal [Java]Algorithms/- LeetCode 2022. 4. 16. 00:18
문제 링크 : Binary Tree Postorder Traversal Binary Tree Postorder 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) 재귀풀이 import java.util.*; class Solution { public List postorderTraversal(TreeNode root) { List answer = new ArrayList(); dfs(root, answer); return ..
-
LeetCode - Maximum Depth of Binary Tree [Java]Algorithms/- LeetCode 2022. 2. 10. 22:30
문제 링크 : Maximum Depth of Binary Tree Maximum Depth of Binary 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) { th..
-
LeetCode - Symmetric Tree [Java]Algorithms/- LeetCode 2022. 2. 9. 21:39
문제 링크 : Symmetric Tree Symmetric 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(i..