This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Input: nums = [2,7,11,15], target = 9 | |
Output: [0,1] | |
Output: Because nums[0] + nums[1] == 9, we return [0, 1]. | |
*/ | |
/** | |
* @param {number[]} nums | |
* @param {number} target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Input: nums = [-1,0,1,2,-1,-4] | |
Output: [[-1,-1,2],[-1,0,1]] | |
*/ | |
//if a+b+c=0 then output contains [a,b,c] | |
class Solution { | |
public List<List<Integer>> threeSum(int[] nums) { | |
//result that stores triplet | |
List<List<Integer>> result= new ArrayList<>(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Definition for a binary tree node. | |
* function TreeNode(val, left, right) { | |
* this.val = (val===undefined ? 0 : val) | |
* this.left = (left===undefined ? null : left) | |
* this.right = (right===undefined ? null : right) | |
* } | |
*/ | |
/** | |
* @param {TreeNode} root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
Input: nums = [-1,2,1,-4], target = 1 | |
Output: 2 | |
Explanation: The sum that is closest to the target is 2. (-1 + 2 + 1 = 2). | |
*/ | |
//------------------------------------------------------------------- | |
/** | |
* @param {number[]} nums |