Algorithm/LeetCode
[LeetCode] Two Sum
정수 배열 nums와 정수인 target이 주어진다. nums에서 합산하면 target이 되는 두 숫자의 인덱스를 반환하라 각 입력에 정확히 하나의 솔루션이 있다고 가정 할 수 있으며 동일한 요소를 두 번 사용할 수 없습니다. 어떤 순서로든 답변을 반환 할 수 있습니다. Constraints: 2
[LeetCode] Top K Frequent Elements
문제 : 비워있지 않은 정수형 배열이 주어질 때, 가장 빈번하게 나오는 요소들인 K를 반환하시오 조건 k가 항상 유효하다고 가정 할 수 있습니다. 1 ≤ k ≤ 고유 요소 수입니다. 알고리즘의 시간 복잡도는 O (n log n)보다 나아야합니다. 여기서 n은 배열의 크기입니다. 답이 고유하다는 것이 보장됩니다. 즉, 상위 k 개의 빈번한 요소 집합이 고유합니다. 어떤 순서로든 답변을 반환 할 수 있습니다. pseudo-code 요구사항 nums배열에서 가장 빈번한 elements를 k개만큼 int[]로 반환하시오 int[] result = new int[k] 초기화 nums 배열 순회 순회 중 가장 빈번한 수를 저장 가장 빈번한 수 인지 순회중 비교 result에 빈번한 수 저장 순회 종료 result ..
[LeetCode] Roman to Integer
문제 : 로마 문자의 문자열을 숫자로 변환하기 Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C 100 D 500 M 1000 Example 1: Input: s = "III" Output: 3 Example 2: Input: s = "IV" Output: 4 Example 3: Input: s = "IX" Output: 9 Example 4: Input: s = "LVIII" Output: 58 Explanation: L = 50, V= 5, III = 3. Example 5: Input: s = "MCMXCIV" Output: 1994 Expla..
[LeetCode] Path Sum Debuging
public static void main(String[] args) { //[5,4,8,11,null,13,4,7,2,null,null,null,1]; Solution s = new Solution(); TreeNode root = new TreeNode(5); root.left = new TreeNode(4); root.right = new TreeNode(8); root.left.left = new TreeNode(11); root.left.right = new TreeNode((Integer)null); root.right.left = new TreeNode(13); root.right.right = new TreeNode(4); root.left.left.left = new TreeNode(7)..
[LeetCode] Path Sum
링크 leetcode.com/problems/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 Given the root of a binary tree and an integer targetSum, return true if the tree has a root-to-leaf path such that adding up all the values along the path equals targetSum. A leaf is a no..
[LeetCode] Binary Tree Inorder TraversalSolution
링크 : leetcode.com/problems/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 이진 트리의 루트가 주어지면 노드 값의 순회하고, 순회를 반환합니다. 조건 : 1. 트리의 노드 수는 [0, 100] 범위에 있습니다. 2. -100 성공 /** * Definition for a binary tree node. * public class T..