- create hash table of <valueOfArray, IndexOfArray> and check diff exists
This file contains hidden or 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
| /** | |
| * @param {number[]} nums ascending sorted array of int | |
| * @return {number[]} | |
| */ | |
| var sortedSquares = function (nums) { | |
| var squaredNums = nums.map(function (val) { | |
| return val * val; | |
| }); | |
| var leftToRight = 0; |