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} x | |
| * @return {number} | |
| */ | |
| var reverse = (x) => { | |
| if (x < 0) { | |
| return -1 * reverse(-x) | |
| } | |
| const solution = (x + "").split('').reverse().join(''); | |
| return (solution > 2 ** 31 - 1) ? 0 : solution; |
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
| #NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. | |
| ; #Warn ; Enable warnings to assist with detecting common errors. | |
| SendMode Input ; Recommended for new scripts due to its superior speed and reliability. | |
| SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. | |
| XButton2 & Tab::AltTab | |
| return | |
| Numpad5:: | |
| Send, git add . {Enter} git commit -m "AutoCommit" {Enter}git push {Enter} |
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 | |
| * @return {number} | |
| */ | |
| var removeDuplicates = function(nums) { | |
| nums.forEach((num,i) => { | |
| if(nums[i+1] !== null && nums[i+1] == nums[i] ){ | |
| nums.splice(i, 1); | |
| console.log(nums) | |
| removeDuplicates(nums) |
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 | |
| * @return {number[]} | |
| */ | |
| var runningSum = function(nums) { | |
| let newNums = []; | |
| let numsSum = 0; | |
| nums.forEach((num,i) =>{ | |
| if(nums[i] !== null){ |
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 {string} s | |
| // * @return {boolean} | |
| // */ | |
| let brackets = { | |
| "(": ")", | |
| "[": "]", | |
| "{": "}", | |
| }; |
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
| let mergeTwoLists = function (l1, l2) { | |
| let dummy = new ListNode(-1); | |
| let head = dummy; | |
| while (l1 !== null && l2 !== null) { | |
| if (l1.val <= l2.val) { | |
| dummy.next = l1; | |
| l1 = l1.next; | |
| } else { | |
| dummy.next = l2; |
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
| /** Initial Hypothesis | |
| * @param {string[]} strs | |
| * @return {string} | |
| */ | |
| var longestCommonPrefix = function(strs) { | |
| let splitWords = []; | |
| let commonPrefix =[]; | |
| strs.forEach((word,i) =>{ | |
| splitWords[i] = word.split(''); | |
| }) |
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 {string} s | |
| * @return {number} | |
| */ | |
| var romanToInt = function(s) { | |
| romanNumerals = { | |
| I: 1, | |
| V: 5, | |
| X: 10, | |
| L: 50, |
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} x | |
| * @return {boolean} | |
| */ | |
| var isPalindrome = function(x) { | |
| let reversedNum = 0 | |
| //Passes | |
| if(x < 0){ | |
| return false; | |
| }else{ |
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} x | |
| * @return {number} | |
| */ | |
| var reverse = function (x) { | |
| return parseFloat(x.toString().split('').reverse().join('')) * Math.sign(x); | |
| }; | |
| //https://www.freecodecamp.org/news/js-basics-how-to-reverse-a-number-9aefc20afa8d/ |