From fadf5cf1c7647e738767a30dd880eb04b215000f Mon Sep 17 00:00:00 2001 From: lachlan-bennetts Date: Mon, 21 Jul 2025 21:12:01 +1000 Subject: [PATCH 1/6] feat: initial commit --- src/questions/Pre-Questions/100.SameTree.ts | 63 +++++++++++++++ .../Pre-Questions/101.SymmetricTree.ts | 45 +++++++++++ .../Pre-Questions/108.MaxDepthOfBinaryTree.ts | 30 +++++++ .../Pre-Questions/118.Pascals-Triangle.ts | 21 +++++ .../Pre-Questions/121.Buy-Sell-Stock.ts | 50 ++++++++++++ .../Pre-Questions/122.Buy-Sell-Stock-II.ts | 0 .../Pre-Questions/123.SingleNumber.ts | 14 ++++ .../Pre-Questions/141.LinkedListCycle.ts | 29 +++++++ .../Pre-Questions/2.AddTwoNumbers.ts | 30 +++++++ ...3.LongestSubstringWithoutRepeatingChars.ts | 23 ++++++ .../5.LongestPalindromicSubstring.ts | 0 src/questions/Pre-Questions/67.Add-Binary.ts | 28 +++++++ .../Pre-Questions/88.Merge-Sorted-Array.ts | 36 +++++++++ .../Pre-Questions/94.TreeOrderTraversal.ts | 81 +++++++++++++++++++ 14 files changed, 450 insertions(+) create mode 100644 src/questions/Pre-Questions/100.SameTree.ts create mode 100644 src/questions/Pre-Questions/101.SymmetricTree.ts create mode 100644 src/questions/Pre-Questions/108.MaxDepthOfBinaryTree.ts create mode 100644 src/questions/Pre-Questions/118.Pascals-Triangle.ts create mode 100644 src/questions/Pre-Questions/121.Buy-Sell-Stock.ts create mode 100644 src/questions/Pre-Questions/122.Buy-Sell-Stock-II.ts create mode 100644 src/questions/Pre-Questions/123.SingleNumber.ts create mode 100644 src/questions/Pre-Questions/141.LinkedListCycle.ts create mode 100644 src/questions/Pre-Questions/2.AddTwoNumbers.ts create mode 100644 src/questions/Pre-Questions/3.LongestSubstringWithoutRepeatingChars.ts create mode 100644 src/questions/Pre-Questions/5.LongestPalindromicSubstring.ts create mode 100644 src/questions/Pre-Questions/67.Add-Binary.ts create mode 100644 src/questions/Pre-Questions/88.Merge-Sorted-Array.ts create mode 100644 src/questions/Pre-Questions/94.TreeOrderTraversal.ts diff --git a/src/questions/Pre-Questions/100.SameTree.ts b/src/questions/Pre-Questions/100.SameTree.ts new file mode 100644 index 00000000..0087d542 --- /dev/null +++ b/src/questions/Pre-Questions/100.SameTree.ts @@ -0,0 +1,63 @@ +// class TreeNode { +// val: number; +// left: TreeNode | null; +// right: TreeNode | null; +// constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { +// this.val = val === undefined ? 0 : val; +// this.left = left === undefined ? null : left; +// this.right = right === undefined ? null : right; +// } +// } + +function isSameTree(p: TreeNode | null, q: TreeNode | null): boolean { + let pCurr = p; + let qCurr = q; + const pStack: TreeNode[] = []; + const qStack: TreeNode[] = []; + + if (q && p) { + qStack.push(q); + pStack.push(p); + } + + while ( + (pCurr !== null || pStack.length > 0) && + (qCurr !== null || qStack.length > 0) + ) { + // 1. Reach the leftmost node of the pCurr node + while (pCurr !== null && qCurr !== null) { + pStack.push(pCurr); + qStack.push(qCurr); + pCurr = pCurr.left; + qCurr = qCurr.left; + } + + if ( + (pCurr && qCurr && pCurr.val !== qCurr.val) || + (pCurr && !qCurr) || + (!pCurr && qCurr) + ) + return false; + + // 2. Current must be null at this point + pCurr = pStack.pop()!; + qCurr = qStack.pop()!; + + if ( + (pCurr && qCurr && pCurr.val !== qCurr.val) || + (pCurr && !qCurr) || + (!pCurr && qCurr) + ) + return false; + + // 3. Visit the right subtree + pCurr = pCurr.right; + qCurr = qCurr.right; + } + return ( + pCurr === null && + qCurr === null && + pStack.length === 0 && + qStack.length === 0 + ); +} diff --git a/src/questions/Pre-Questions/101.SymmetricTree.ts b/src/questions/Pre-Questions/101.SymmetricTree.ts new file mode 100644 index 00000000..48683751 --- /dev/null +++ b/src/questions/Pre-Questions/101.SymmetricTree.ts @@ -0,0 +1,45 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function isSymmetric(root: TreeNode | null): boolean { + if (!root) { + return false; + } + const lhs = root.left; + const rhs = root.right; + let matched = true; + + const dfs = (lhs: TreeNode | null, rhs: TreeNode | null) => { + if (!matched) { + return; + } + if ((lhs && !rhs) || (!lhs && rhs)) { + matched = false; + return; + } + if (!lhs || !rhs) { + return; + } + if (lhs.val !== rhs.val) { + matched = false; + return; + } + + dfs(lhs.left, rhs.right); + dfs(lhs.right, rhs.left); + }; + + dfs(lhs, rhs); + return matched; +} diff --git a/src/questions/Pre-Questions/108.MaxDepthOfBinaryTree.ts b/src/questions/Pre-Questions/108.MaxDepthOfBinaryTree.ts new file mode 100644 index 00000000..02ccbc0f --- /dev/null +++ b/src/questions/Pre-Questions/108.MaxDepthOfBinaryTree.ts @@ -0,0 +1,30 @@ +/** + * Definition for a binary tree node. + * class TreeNode { + * val: number + * left: TreeNode | null + * right: TreeNode | null + * constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.left = (left===undefined ? null : left) + * this.right = (right===undefined ? null : right) + * } + * } + */ + +function maxDepth(root: TreeNode | null): number { + if (!root) return 0; + + const dfs = (node, depth) => { + if (!node) return 0; + + const lhsDepth = dfs(node.left, depth + 1); + const rhsDepth = dfs(node.right, depth + 1); + + const currentDepth = + lhsDepth > rhsDepth ? lhsDepth : rhsDepth > depth ? rhsDepth : depth; + return currentDepth; + }; + + return dfs(root, 0); +} diff --git a/src/questions/Pre-Questions/118.Pascals-Triangle.ts b/src/questions/Pre-Questions/118.Pascals-Triangle.ts new file mode 100644 index 00000000..b4975bec --- /dev/null +++ b/src/questions/Pre-Questions/118.Pascals-Triangle.ts @@ -0,0 +1,21 @@ +function generate(numRows: number): number[][] { + if (numRows === 0) return []; + if (numRows === 1) return [[1]]; + + let result: number[][] = [[1]]; + + for (let i: number = 1; i < numRows; i++) { + let prevRow: number[] = result[i - 1]; + let newRow: number[] = []; + + newRow.push(1); + + for (let j: number = 1; j < prevRow.length; j++) { + newRow.push(prevRow[j - 1] + prevRow[j]); + } + + newRow.push(1); + result.push(newRow); + } + return result; +} diff --git a/src/questions/Pre-Questions/121.Buy-Sell-Stock.ts b/src/questions/Pre-Questions/121.Buy-Sell-Stock.ts new file mode 100644 index 00000000..eec8b7f8 --- /dev/null +++ b/src/questions/Pre-Questions/121.Buy-Sell-Stock.ts @@ -0,0 +1,50 @@ +/* +You are given an array prices where prices[i] is the price of a given stock on the ith day. + +You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. + +Return the maximum profit you can achieve from this transaction. If you cannot achieve any profit, return 0. + + + +Example 1: + +Input: prices = [7,1,5,3,6,4] +Output: 5 +Explanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5. +Note that buying on day 2 and selling on day 1 is not allowed because you must buy before you sell. +Example 2: + +Input: prices = [7,6,4,3,1] +Output: 0 +Explanation: In this case, no transactions are done and the max profit = 0. + + +Constraints: + +1 <= prices.length <= 105 +0 <= prices[i] <= 104 +*/ + +function maxProfit(prices: number[]): number { + if (prices.length === 0) return 0; + + let minPrice = prices[0]; + let maxProfit = 0; + + for (let i = 1; i < prices.length; i++) { + const currentPrice = prices[i]; + if (currentPrice < minPrice) { + minPrice = currentPrice; + } else { + const profit = currentPrice - minPrice; + if (profit > maxProfit) { + maxProfit = profit; + } + } + } + + return maxProfit; +} + +maxProfit([7, 5, 4, 3, 2, 8]); diff --git a/src/questions/Pre-Questions/122.Buy-Sell-Stock-II.ts b/src/questions/Pre-Questions/122.Buy-Sell-Stock-II.ts new file mode 100644 index 00000000..e69de29b diff --git a/src/questions/Pre-Questions/123.SingleNumber.ts b/src/questions/Pre-Questions/123.SingleNumber.ts new file mode 100644 index 00000000..efe737d7 --- /dev/null +++ b/src/questions/Pre-Questions/123.SingleNumber.ts @@ -0,0 +1,14 @@ +function singleNumber(nums: number[]): number { + const numSet = new Set(); + + for (let i = 0; i < nums.length; i++) { + const num = nums[i]; + if (numSet.has(num)) { + numSet.delete(num); + } else { + numSet.add(num); + } + } + + return numSet.values().next().value; +} diff --git a/src/questions/Pre-Questions/141.LinkedListCycle.ts b/src/questions/Pre-Questions/141.LinkedListCycle.ts new file mode 100644 index 00000000..8359feec --- /dev/null +++ b/src/questions/Pre-Questions/141.LinkedListCycle.ts @@ -0,0 +1,29 @@ +/** + * Definition for singly-linked list. + * class ListNode { + * val: number + * next: ListNode | null + * constructor(val?: number, next?: ListNode | null) { + * this.val = (val===undefined ? 0 : val) + * this.next = (next===undefined ? null : next) + * } + * } + */ + +function hasCycle(head: ListNode | null): boolean { + const nodeSet = new Set(); + nodeSet.add(head?.val); + let current = new ListNode(0, head); + let bool = false; + + while (bool) { + if (current.next === null) break; + if (nodeSet.has(current.next.val)) { + bool = true; + } else { + nodeSet.add(current.next.val); + current = current.next; + } + } + return bool; +} diff --git a/src/questions/Pre-Questions/2.AddTwoNumbers.ts b/src/questions/Pre-Questions/2.AddTwoNumbers.ts new file mode 100644 index 00000000..0082bf95 --- /dev/null +++ b/src/questions/Pre-Questions/2.AddTwoNumbers.ts @@ -0,0 +1,30 @@ +function addTwoNumbers( + l1: ListNode | null, + l2: ListNode | null, +): ListNode | null { + let dummy = new ListNode(0); + let current = dummy; + let carry = 0; + + while (l1 !== null || l2 !== null) { + let sum = carry; + if (l1 !== null) { + sum += l1.val; + l1 = l1.next; + } + if (l2 !== null) { + sum += l2.val; + l2 = l2.next; + } + + carry = Math.floor(sum / 10); + current.next = new ListNode(sum % 10); + current = current.next; + } + + if (carry > 0) { + current.next = new ListNode(carry); + } + + return dummy.next; +} diff --git a/src/questions/Pre-Questions/3.LongestSubstringWithoutRepeatingChars.ts b/src/questions/Pre-Questions/3.LongestSubstringWithoutRepeatingChars.ts new file mode 100644 index 00000000..94944297 --- /dev/null +++ b/src/questions/Pre-Questions/3.LongestSubstringWithoutRepeatingChars.ts @@ -0,0 +1,23 @@ +function lengthOfLongestSubstring(s: string): number { + let count = 0; + let finalCount = 0; + let obj = {}; + let j = 1; + + for (let i = 0; i <= s.length - 1; i++) { + if (!obj[s[i]]) { + obj[s[i]] = s[i]; + count += 1; + finalCount = Math.max(count, finalCount); + } else { + count = 1; + i = j; + obj = { + [s[i]]: s[i], + }; + j++; + } + } + + return finalCount; +} diff --git a/src/questions/Pre-Questions/5.LongestPalindromicSubstring.ts b/src/questions/Pre-Questions/5.LongestPalindromicSubstring.ts new file mode 100644 index 00000000..e69de29b diff --git a/src/questions/Pre-Questions/67.Add-Binary.ts b/src/questions/Pre-Questions/67.Add-Binary.ts new file mode 100644 index 00000000..03a56d1f --- /dev/null +++ b/src/questions/Pre-Questions/67.Add-Binary.ts @@ -0,0 +1,28 @@ +function addBinary(a: string, b: string): string { + let result: string = ''; + let carry: number = 0; + let i: number = a.length - 1; + let j: number = b.length - 1; + + while (i >= 0 || j >= 0) { + let sum: number = carry; + + if (i >= 0) { + sum += parseInt(a[i--]); + } + + if (j >= 0) { + sum += parseInt(b[j--]); + } + + result = (sum % 2) + result; + carry = Math.floor(sum / 2); + } + + if (carry > 0) { + result = carry + result; + } + + console.log(result); + return result; +} diff --git a/src/questions/Pre-Questions/88.Merge-Sorted-Array.ts b/src/questions/Pre-Questions/88.Merge-Sorted-Array.ts new file mode 100644 index 00000000..61d624a7 --- /dev/null +++ b/src/questions/Pre-Questions/88.Merge-Sorted-Array.ts @@ -0,0 +1,36 @@ +/** + * @param {number[]} nums1 + * @param {number} m + * @param {number[]} nums2 + * @param {number} n + * @return {void} Do not return anything, modify nums1 in-place instead. + */ +var merge = function(nums1, m, nums2, n) { + let i = m - 1; + let j = n - 1; + let k = m + n - 1; + + while (i >= 0 && j >= 0) { + if (nums1[i] < nums2[j]) { + nums1[k] = nums2[j]; + k--; + j--; + } else { + nums1[k] = nums1[i]; + k--; + i--; + } + } + + while (j >= 0) { + nums1[k] = nums2[j]; + k--; + j--; + } + + while (i >= 0) { + nums1[k] = nums1[i]; + k--; + i--; + } +}; diff --git a/src/questions/Pre-Questions/94.TreeOrderTraversal.ts b/src/questions/Pre-Questions/94.TreeOrderTraversal.ts new file mode 100644 index 00000000..a1b516c0 --- /dev/null +++ b/src/questions/Pre-Questions/94.TreeOrderTraversal.ts @@ -0,0 +1,81 @@ +class TreeNode { + val: number; + left: TreeNode | null; + right: TreeNode | null; + constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + this.val = val === undefined ? 0 : val; + this.left = left === undefined ? null : left; + this.right = right === undefined ? null : right; + } +} + +// Iterative solution. +function inorderTraversal(root: TreeNode | null): number[] { + const ans: number[] = []; + const stack: TreeNode[] = []; + let current = root; + + while (current !== null || stack.length > 0) { + // 1. Reach the leftmost node of the current node + while (current !== null) { + stack.push(current); + current = current.left; + } + + // 2. Current must be null at this point + current = stack.pop()!; + ans.push(current.val); + + // 3. Visit the right subtree + current = current.right; + } + + return ans; +} + +/* +* Failed Solution +* const ans: number[] = []; +* const store: TreeNode[] = []; +* if (!root) { +* return []; +* } else { +* store.push(root); +* } + +* while (store.length > 0) { +* let root = store.at(-1); +* if (!root) { +* break; +* } + +* if (root.left) { +* store.push(root.left); +* continue; +* } +* store.pop(); +* ans.push(root.val); + +* if (root.right) { +* store.push(root.right); +* } +* } +* return ans; +* +* Why did the solution fail? I think there were a couple of reasons. The root.left did work but wouldn't account +* future left cases. Furthermore the assignment around root failed to assign correctly. +*/ + +// Regression solution. +// const ans: number[] = []; +// const dfs = (root: TreeNode | null) => { +// if (!root) { +// return; +// } +// console.log(root.left) +// dfs(root.left); +// ans.push(root.val); +// dfs(root.right); +// }; +// dfs(root); +// return ans; From 31242017469a8351a5092eba9d53b599ecc295a4 Mon Sep 17 00:00:00 2001 From: lachlan-bennetts Date: Mon, 21 Jul 2025 21:33:35 +1000 Subject: [PATCH 2/6] feat: added interface file --- .../Pre-Questions/108.MaxDepthOfBinaryTree.ts | 2 ++ src/questions/interfaces.ts | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 src/questions/interfaces.ts diff --git a/src/questions/Pre-Questions/108.MaxDepthOfBinaryTree.ts b/src/questions/Pre-Questions/108.MaxDepthOfBinaryTree.ts index 02ccbc0f..a6ecb8e0 100644 --- a/src/questions/Pre-Questions/108.MaxDepthOfBinaryTree.ts +++ b/src/questions/Pre-Questions/108.MaxDepthOfBinaryTree.ts @@ -12,6 +12,8 @@ * } */ +import { TreeNode } from '../interfaces'; + function maxDepth(root: TreeNode | null): number { if (!root) return 0; diff --git a/src/questions/interfaces.ts b/src/questions/interfaces.ts new file mode 100644 index 00000000..2ec33d90 --- /dev/null +++ b/src/questions/interfaces.ts @@ -0,0 +1,10 @@ +export class TreeNode { + val: number; + left: TreeNode | null; + right: TreeNode | null; + constructor(val?: number, left?: TreeNode | null, right?: TreeNode | null) { + this.val = val === undefined ? 0 : val; + this.left = left === undefined ? null : left; + this.right = right === undefined ? null : right; + } +} From 94ca4f3818d8e12269c5530b2c7fb07178d51ef4 Mon Sep 17 00:00:00 2001 From: lachlan-bennetts Date: Mon, 21 Jul 2025 21:50:13 +1000 Subject: [PATCH 3/6] feat: 218.ContainsDuplicates --- .../75-Questions/218.ContainsDuplicate.ts | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/questions/75-Questions/218.ContainsDuplicate.ts diff --git a/src/questions/75-Questions/218.ContainsDuplicate.ts b/src/questions/75-Questions/218.ContainsDuplicate.ts new file mode 100644 index 00000000..517b740a --- /dev/null +++ b/src/questions/75-Questions/218.ContainsDuplicate.ts @@ -0,0 +1,28 @@ +function containsDuplicate(nums: number[]): boolean { + const numSet = new Set(); + let res = false; + let i = 0; + + for (i = 0; i < nums.length; i++) { + if (numSet.has(nums[i])) break; + else numSet.add(nums[i]); + } + + return i === nums.length ? false : true; +} + +// First attempt, actually lowkey better. +// function containsDuplicate(nums: number[]): boolean { +// const numSet = new Set(); +// let res = false; + +// for (let i = 0; i < nums.length; i++) { +// if (numSet.has(nums[i])) { +// res = true; +// break; +// } +// numSet.add(nums[i]); +// } + +// return res; +// } From 0a619e086145f50d677ac539d158750938d10b6f Mon Sep 17 00:00:00 2001 From: lachlan-bennetts Date: Mon, 21 Jul 2025 22:31:57 +1000 Subject: [PATCH 4/6] feat:268 Missing Number, some intuitive solutions for sure --- .../75-Questions/268.MissingNumber.ts | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/questions/75-Questions/268.MissingNumber.ts diff --git a/src/questions/75-Questions/268.MissingNumber.ts b/src/questions/75-Questions/268.MissingNumber.ts new file mode 100644 index 00000000..9085f790 --- /dev/null +++ b/src/questions/75-Questions/268.MissingNumber.ts @@ -0,0 +1,36 @@ +function missingNumber(nums: number[]): number { + const set = new Set( + Array.from({ length: nums.length + 1 }, (_, i) => i), + ); + + for (let i = 0; i < nums.length; i++) { + set.delete(nums[i]); + } + + return set.values().next().value; +} + +// Set attempt, worked but slow. +// function missingNumber(nums: number[]): number { +// const set = new Set( +// Array.from({ length: nums.length + 1 }, (_, i) => i), +// ); + +// for (let i = 0; i < nums.length; i++) { +// set.delete(nums[i]); +// } + +// return set.values().next().value; +// } + +// Simple but elegant solution +// function missingNumber(nums: number[]): number { +// let expectedSum = 0; +// let foundSum = 0; + +// for (let i = 0; i < nums.length; i++) { +// expectedSum += i + 1; +// foundSum += nums[i]; +// } +// return expectedSum - foundSum; +// }; From 5cb41a3789153faaa57c51022f2b1b721f61d360 Mon Sep 17 00:00:00 2001 From: lachlan-bennetts Date: Sun, 27 Jul 2025 00:53:38 +1000 Subject: [PATCH 5/6] 448.Find Disappeared numbers --- .../448.FIndAllNumsDisappearedInArr.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/questions/75-Questions/448.FIndAllNumsDisappearedInArr.ts diff --git a/src/questions/75-Questions/448.FIndAllNumsDisappearedInArr.ts b/src/questions/75-Questions/448.FIndAllNumsDisappearedInArr.ts new file mode 100644 index 00000000..fdb0efc0 --- /dev/null +++ b/src/questions/75-Questions/448.FIndAllNumsDisappearedInArr.ts @@ -0,0 +1,15 @@ +function findDisappearedNumbers(nums: number[]): number[] { + const arr: number[] = []; + + for (let i = 0; i > nums.length; i++) { + const offset = nums[i]; + nums[offset] = -nums[offset]; + } + + for (let i = 0; i > nums.length; i++) { + if (nums[i] > 0) arr.push(nums[i]); + } + + console.log(nums); + return arr; +} From 4a341424d1e8a4afb628370bb55be4fef5e03d99 Mon Sep 17 00:00:00 2001 From: lachlan-bennetts Date: Sun, 3 Aug 2025 12:13:13 +1000 Subject: [PATCH 6/6] feat: more easy questions --- .../121.BestTimetoBuyandSellStock.ts | 17 +++++++++++++++++ src/questions/75-Questions/136.SingleNumber.ts | 10 ++++++++++ .../448.FIndAllNumsDisappearedInArr.ts | 2 ++ tsconfig.json | 1 + 4 files changed, 30 insertions(+) create mode 100644 src/questions/75-Questions/121.BestTimetoBuyandSellStock.ts create mode 100644 src/questions/75-Questions/136.SingleNumber.ts create mode 100644 tsconfig.json diff --git a/src/questions/75-Questions/121.BestTimetoBuyandSellStock.ts b/src/questions/75-Questions/121.BestTimetoBuyandSellStock.ts new file mode 100644 index 00000000..4a42a5d0 --- /dev/null +++ b/src/questions/75-Questions/121.BestTimetoBuyandSellStock.ts @@ -0,0 +1,17 @@ +function maxProfit(prices: number[]): number { + if (prices.length === 0) return 0; + + let minPrice = prices[0]; + let maxProfit = 0; + + for (let i = 1; i < prices.length; i++) { + if (prices[i] < minPrice) { + minPrice = prices[i]; + continue; + } + maxProfit = + prices[i] - minPrice > maxProfit ? prices[i] - minPrice : maxProfit; + } + + return maxProfit; +} diff --git a/src/questions/75-Questions/136.SingleNumber.ts b/src/questions/75-Questions/136.SingleNumber.ts new file mode 100644 index 00000000..2324c737 --- /dev/null +++ b/src/questions/75-Questions/136.SingleNumber.ts @@ -0,0 +1,10 @@ +// XOR +function singleNumber(nums: number[]): number { + // using xor + let total = 0; + for (let i = 0; i < nums.length; i++) { + total ^= nums[i]; + } + + return total; +} diff --git a/src/questions/75-Questions/448.FIndAllNumsDisappearedInArr.ts b/src/questions/75-Questions/448.FIndAllNumsDisappearedInArr.ts index fdb0efc0..7a4a8ae7 100644 --- a/src/questions/75-Questions/448.FIndAllNumsDisappearedInArr.ts +++ b/src/questions/75-Questions/448.FIndAllNumsDisappearedInArr.ts @@ -13,3 +13,5 @@ function findDisappearedNumbers(nums: number[]): number[] { console.log(nums); return arr; } + +findDisappearedNumbers([1, 1, 4, 2]); diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..0967ef42 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1 @@ +{}