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
import fetch from "node-fetch"; | |
import dotenv from "dotenv"; | |
// Load environment variables from .env file | |
dotenv.config(); | |
// Type definitions for better type safety | |
interface WeatherResponse { | |
city: string; | |
temperature: number; |
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
/** | |
* Find all unique pairs of numbers in an array whose sum equals a target value. | |
* | |
* @param arr - Array of integers | |
* @param target - Target sum | |
* @returns Array of unique pairs | |
*/ | |
function findPairs(arr: number[], target: number): number[][] { | |
if (!arr || arr.length < 2) return []; |