Skip to content

Commit

Permalink
160th Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Shyam-Chen committed Jun 30, 2024
1 parent 638b4e6 commit 6eca558
Show file tree
Hide file tree
Showing 47 changed files with 89 additions and 71 deletions.
42 changes: 21 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Ace Coding Interview with 75 Qs
| 206. Reverse Linked List | [Solution][206] | Easy |
| 2130. Maximum Twin Sum of a Linked List | Solution | Medium |

[206]: ./src//page-2/206.%20Reverse%20Linked%20List/reverse-list.ts
[206]: ./src/page-2/206.%20Reverse%20Linked%20List/reverseList.ts

| Binary Tree - DFS | | |
| -------------------------------------------- | --------------- | ------ |
Expand All @@ -155,7 +155,7 @@ Ace Coding Interview with 75 Qs
| 1372. Longest ZigZag Path in a Binary Tree | Solution | Medium |
| 236. Lowest Common Ancestor of a Binary Tree | Solution | Medium |

[104]: ./src//page-2/104.%20Maximum%20Depth%20of%20Binary%20Tree/max-depth.ts
[104]: ./src/page-2/104.%20Maximum%20Depth%20of%20Binary%20Tree/maxDepth.ts

| Binary Tree - BFS | | |
| ---------------------------------------- | -------- | ------ |
Expand Down Expand Up @@ -218,8 +218,8 @@ Ace Coding Interview with 75 Qs
| 136. Single Number | [Solution][136] | Easy |
| 1318. Minimum Flips to Make a OR b Equal to c | Solution | Medium |

[338]: ./src/page-4/338.%20Counting%20Bits/count-bits.ts
[136]: ./src/page-2/136.%20Single%20Number/single-number.ts
[338]: ./src/page-4/338.%20Counting%20Bits/countBits.ts
[136]: ./src/page-2/136.%20Single%20Number/singleNumber.ts

| Trie | | |
| --------------------------------- | -------- | ------ |
Expand Down Expand Up @@ -282,7 +282,7 @@ Must-do List for Interview Prep
[26]: ./src/page-1/26.%20Remove%20Duplicates%20from%20Sorted%20Array/removeDuplicates.ts
[189]: ./src/page-2/189.%20Rotate%20Array/rotate.ts
[13]: ./src/page-1/13.%20Roman%20to%20Integer/romanToInt.ts
[58]: ./src/page-1/58.%20Length%20of%20Last%20Word/length-of-last-word.ts
[58]: ./src/page-1/58.%20Length%20of%20Last%20Word/lengthOfLastWord.ts
[14]: ./src/page-1/14.%20Longest%20Common%20Prefix/longestCommonPrefix.ts
[6]: ./src/page-1/6.%20Zigzag%20Conversion/convert.ts
[28]: ./src/page-1/28.%20Find%20the%20Index%20of%20the%20First%20Occurrence%20in%20a%20String/strStr.ts
Expand Down Expand Up @@ -343,7 +343,7 @@ Must-do List for Interview Prep
| 224. Basic Calculator | Solution | Hard |

[20]: ./src/page-1/20.%20Valid%20Parentheses/isValid.ts
[155]: ./src/page-2/155.%20Min%20Stack/min-stack.ts
[155]: ./src/page-2/155.%20Min%20Stack/MinStack.ts

| Linked List | | |
| ----------------------------------------- | --------------- | ------ |
Expand All @@ -359,7 +359,7 @@ Must-do List for Interview Prep
| 86. Partition List | Solution | Medium |
| 146. LRU Cache | Solution | Medium |

[141]: ./src/page-2/141.%20Linked%20List%20Cycle/has-cycle.ts
[141]: ./src/page-2/141.%20Linked%20List%20Cycle/hasCycle.ts
[2]: ./src/page-1/2.%20Add%20Two%20Numbers/addTwoNumbers.ts
[21]: ./src/page-1/21.%20Merge%20Two%20Sorted%20Lists/mergeTwoLists.ts

Expand All @@ -380,10 +380,10 @@ Must-do List for Interview Prep
| 222. Count Complete Tree Nodes | Solution | Easy |
| 236. Lowest Common Ancestor of a Binary Tree | Solution | Medium |

[104]: ./src/page-2/104.%20Maximum%20Depth%20of%20Binary%20Tree/max-depth.ts
[104]: ./src/page-2/104.%20Maximum%20Depth%20of%20Binary%20Tree/maxDepth.ts
[100]: ./src/page-1/100.%20Same%20Tree/isSameTree.ts
[101]: ./src/page-2/101.%20Symmetric%20Tree/is-symmetric.ts
[112]: ./src/page-2/112.%20Path%20Sum/has-path-sum.ts
[101]: ./src/page-2/101.%20Symmetric%20Tree/isSymmetric.ts
[112]: ./src/page-2/112.%20Path%20Sum/hasPathSum.ts

| Binary Tree BFS | | |
| --------------------------------------------- | -------- | ------ |
Expand Down Expand Up @@ -443,7 +443,7 @@ Must-do List for Interview Prep
| 53. Maximum Subarray | [Solution][53] | Medium |
| 918. Maximum Sum Circular Subarray | Solution | Medium |

[53]: ./src/page-1/53.%20Maximum%20Subarray/max-sub-array.ts
[53]: ./src/page-1/53.%20Maximum%20Subarray/maxSubArray.ts

| Binary Search | | |
| ----------------------------------------------------------- | -------------- | ------ |
Expand All @@ -455,8 +455,8 @@ Must-do List for Interview Prep
| 153. Find Minimum in Rotated Sorted Array | Solution | Medium |
| 4. Median of Two Sorted Arrays | [Solution][4] | Hard |

[35]: ./src/page-1/35.%20Search%20Insert%20Position/search-insert.ts
[34]: ./src/page-1/34.%20Find%20First%20and%20Last%20Position%20of%20Element%20in%20Sorted%20Array/search-range.ts
[35]: ./src/page-1/35.%20Search%20Insert%20Position/searchInsert.ts
[34]: ./src/page-1/34.%20Find%20First%20and%20Last%20Position%20of%20Element%20in%20Sorted%20Array/searchRange.ts
[4]: ./src/page-1/4.%20Median%20of%20Two%20Sorted%20Arrays/findMedianSortedArrays.ts

| Heap | | |
Expand All @@ -475,10 +475,10 @@ Must-do List for Interview Prep
| 137. Single Number II | Solution | Medium |
| 201. Bitwise AND of Numbers Range | Solution | Medium |

[67]: ./src/page-1/67.%20Add%20Binary/add-binary.ts
[190]: ./src/page-2/190.%20Reverse%20Bits/reverse-bits.ts
[191]: ./src/page-2/191.%20Number%20of%201%20Bits/hamming-weight.ts
[136]: ./src/page-2/136.%20Single%20Number/single-number.ts
[67]: ./src/page-1/67.%20Add%20Binary/addBinary.ts
[190]: ./src/page-2/190.%20Reverse%20Bits/reverseBits.ts
[191]: ./src/page-2/191.%20Number%20of%201%20Bits/hammingWeight.ts
[136]: ./src/page-2/136.%20Single%20Number/singleNumber.ts

| Math | | |
| ------------------------------ | -------------- | ------ |
Expand All @@ -490,9 +490,9 @@ Must-do List for Interview Prep
| 149. Max Points on a Line | Solution | Hard |

[9]: ./src/page-1/9.%20Palindrome%20Number/isPalindrome.ts
[66]: ./src/page-1/66.%20Plus%20One/plus-one.ts
[69]: ./src/page-1/69.%20Sqrt(x)/my-sqrt.ts
[50]: ./src/page-1/50.%20Pow(x,%20n)/pow.ts
[66]: ./src/page-1/66.%20Plus%20One/plusOne.ts
[69]: ./src/page-1/69.%20Sqrt(x)/mySqrt.ts
[50]: ./src/page-1/50.%20Pow(x,%20n)/myPow.ts

| 1D DP | | |
| ----------------------------------- | -------------- | ------ |
Expand All @@ -502,7 +502,7 @@ Must-do List for Interview Prep
| 322. Coin Change | Solution | Medium |
| 300. Longest Increasing Subsequence | Solution | Medium |

[70]: ./src/page-1/70.%20Climbing%20Stairs/climb-stairs.ts
[70]: ./src/page-1/70.%20Climbing%20Stairs/climbStairs.ts

| Multidimensional DP | | |
| ---------------------------------------- | ------------- | ------ |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateBinaryTree } from '~/utils/binary-tree';

import { isSymmetric } from './is-symmetric';
import { isSymmetric } from './isSymmetric';

describe('101. Symmetric Tree', () => {
test('isSymmetric', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateBinaryTree } from '~/utils/binary-tree';

import { maxDepth } from './max-depth';
import { maxDepth } from './maxDepth';

describe('104. Maximum Depth of Binary Tree', () => {
test('maxDepth', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateBinaryTree } from '~/utils/binary-tree';

import { levelOrderBottom } from './level-order-bottom';
import { levelOrderBottom } from './levelOrderBottom';

describe('107. Binary Tree Level Order Traversal II', () => {
test('levelOrderBottom', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateBinaryTree } from '~/utils/binary-tree';

import { minDepth } from './min-depth';
import { minDepth } from './minDepth';

describe('111. Minimum Depth of Binary Tree', () => {
test('minDepth', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateBinaryTree } from '~/utils/binary-tree';

import { hasPathSum } from './has-path-sum';
import { hasPathSum } from './hasPathSum';

describe('112. Path Sum', () => {
test('hasPathSum', () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getRow } from './get-row';
import { getRow } from './getRow';

describe("119. Pascal's Triangle II", () => {
test('getRow', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { singleNumber } from './single-number';
import { singleNumber } from './singleNumber';

describe('136. Single Number', () => {
test('singleNumber', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { generateLinkedListCycle } from '~/utils/linked-list';

import { hasCycle } from './has-cycle';
import { hasCycle } from './hasCycle';

describe('141. Linked List Cycle', () => {
test('hasCycle', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MinStack } from './min-stack';
import { MinStack } from './MinStack';

describe('155. Min Stack', () => {
test('MinStack', () => {
Expand Down
36 changes: 36 additions & 0 deletions src/page-2/155. Min Stack/MinStack.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* Accepted
*/
export class MinStack {
stack: number[];
minStack: number[];

constructor() {
this.stack = [];
this.minStack = [];
}

push(val: number): void {
this.stack.push(val);

if (!this.minStack.length || (this.minStack.length && this.getMin() >= val)) {
this.minStack.push(val);
}
}

pop(): void {
const removed = this.stack.pop();

if (this.getMin() === removed) {
this.minStack.pop();
}
}

top(): number {
return this.stack[this.stack.length - 1];
}

getMin(): number {
return this.minStack[this.minStack.length - 1];
}
}
22 changes: 0 additions & 22 deletions src/page-2/155. Min Stack/min-stack.ts

This file was deleted.

16 changes: 10 additions & 6 deletions src/page-2/189. Rotate Array/rotate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@ import { rotate } from './rotate';

describe('189. Rotate Array', () => {
test('rotate', () => {
const case1 = [1, 2, 3, 4, 5, 6, 7];
rotate(case1, 3);
expect(case1).toStrictEqual([5, 6, 7, 1, 2, 3, 4]);
{
const nums = [1, 2, 3, 4, 5, 6, 7];
rotate(nums, 3);
expect(nums).toStrictEqual([5, 6, 7, 1, 2, 3, 4]);
}

const case2 = [-1, -100, 3, 99];
rotate(case2, 2);
expect(case2).toStrictEqual([3, 99, -1, -100]);
{
const nums = [-1, -100, 3, 99];
rotate(nums, 2);
expect(nums).toStrictEqual([3, 99, -1, -100]);
}
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { reverseBits, reverseBits2 } from './reverse-bits';
import { reverseBits, reverseBits2 } from './reverseBits';

describe('190. Reverse Bits', () => {
test('reverseBits', () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { hammingWeight } from './hamming-weight';
import { hammingWeight } from './hammingWeight';

describe('191. Number of 1 Bits', () => {
test('hammingWeight', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { stringify } from 'flatted';

import { generateLinkedList } from '~/utils/linked-list';

import { reverseList } from './reverse-list';
import { reverseList } from './reverseList';

describe('206. Reverse Linked List', () => {
test('reverseList', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isPowerOfTwo, isPowerOfTwo2, isPowerOfTwo3 } from './is-power-of-two';
import { isPowerOfTwo, isPowerOfTwo2, isPowerOfTwo3 } from './isPowerOfTwo';

describe('231. Power of Two', () => {
test('isPowerOfTwo', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { addDigits, addDigits2, addDigits3, addDigits4, addDigits5 } from './add-digits';
import { addDigits, addDigits2, addDigits3, addDigits4, addDigits5 } from './addDigits';

describe('258. Add Digits', () => {
test('addDigits', () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { missingNumber } from './missing-number';
import { missingNumber } from './missingNumber';

describe('268. Missing Number', () => {
test('missingNumber', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { isPowerOfThree, isPowerOfThree2, isPowerOfThree3 } from './is-power-of-three';
import { isPowerOfThree, isPowerOfThree2, isPowerOfThree3 } from './isPowerOfThree';

describe('326. Power of Three', () => {
test('isPowerOfThree', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { countBits } from './count-bits';
import { countBits } from './countBits';

describe('338. Counting Bits', () => {
test('countBits', () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { reverseString, reverseString2 } from './reverse-string';
import { reverseString, reverseString2 } from './reverseString';

describe('344. Reverse String', () => {
test('reverseString', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getSum, getSum2 } from './get-sum';
import { getSum, getSum2 } from './getSum';

describe('371. Sum of Two Integers', () => {
test('getSum', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { fizzBuzz } from './fizz-buzz';
import { fizzBuzz } from './fizzBuzz';

describe('412. Fizz Buzz', () => {
test('fizzBuzz', () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { convertToBase7, convertToBase72 } from './convert-to-base7';
import { convertToBase7, convertToBase72 } from './convertToBase7';

describe('504. Base 7', () => {
test('convertToBase7', () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { replaceWords } from './replace-words';
import { replaceWords } from './replaceWords';

describe('648. Replace Words', () => {
test('replaceWords', () => {
Expand Down

0 comments on commit 6eca558

Please sign in to comment.