JAVA_Two Sum IV - Input is a BST_LeetCode 653


JAVA_Two Sum IV - Input is a BST_LeetCode 653

JAVA_Two Sum IV - Input is a BST_LeetCode 653 풀이 class Solution { Set<Integer> res = new HashSet<>(); public boolean findTarget(TreeNode root, int k) { if(root == null) return false; if(res.contains(k-root.val)) return true; res.add(root.val); return findTarget(root.left,k) || findTarget(root.right,k); } } * 출처 Two Sum IV - Input is a BST - LeetCode Two Sum IV - Input is a BST - Given the root of a binary search tree and an integer k, return true if there exist two elements in the BST such that ...


#JAVA #JAVA_LeetCode653 #JAVA_TwoSumIV_InputisaBST #JAVA_TwoSumIV_InputisaBST_LeetCode653 #TwoSumIV_InputisaBST_LeetCode653

원문링크 : JAVA_Two Sum IV - Input is a BST_LeetCode 653