Skip to content

Instantly share code, notes, and snippets.

View VictoryIfebhor's full-sized avatar

Victory Ifebhor VictoryIfebhor

View GitHub Profile
@VictoryIfebhor
VictoryIfebhor / groupAnagrams.ts
Last active October 11, 2025 00:14
Leetcode 49. Group Anagrams
function groupAnagrams(strs: string[]): string[][] {
const wordTracker: Map<string, string[]> = new Map();
for (let i = 0; i < strs.length; i++) {
const sorted = strs[i].split('').sort().join('');
if (wordTracker.has(sorted)) {
wordTracker.get(sorted).push(strs[i]);
} else {
wordTracker.set(sorted, [strs[i]]);
}
}
@VictoryIfebhor
VictoryIfebhor / twoSum.ts
Created October 9, 2025 13:16
Leetcode 1. Two Sum
function twoSum(nums: number[], target: number): number[] {
const numTracker: Map<number, number> = new Map();
for (let i = 0; i < nums.length; i++) {
const balance = target - nums[i];
if (numTracker.has(balance)) {
return [numTracker.get(balance), i];
}
numTracker.set(nums[i], i)
}
@VictoryIfebhor
VictoryIfebhor / valid_anagram.js
Created October 8, 2025 21:24
Leet code - 242. Valid Anagram
/**
* @param {string} s
* @param {string} t
* @return {boolean}
*/
var isAnagram = function(s, t) {
const first_length = s.length;
const second_length = t.length;
if (first_length !== second_length) {
@VictoryIfebhor
VictoryIfebhor / contains_duplicate.js
Last active October 8, 2025 21:27
Leetcode 217. Contains Duplicate
/**
* @param {number[]} nums
* @return {boolean}
*/
var containsDuplicate = function(nums) {
const numsSet = new Set();
for (num of nums) {
if (numsSet.has(num)) {
return true;