79. Word Search Leetcode solution in JavaScript (js)

0 Problem Given an m x n grid of characters board and a string word, return true if word exists in the grid. The word can be constructed from letters of sequentially adjacent cells, where adjacent cells are horizontally or vertically neighboring. The same letter cell may not be used more than once. Example 1: Input: board = [[“A”,”B”,”C”,”E”],[“S”,”F”,”C”,”S”],[“A”,”D”,”E”,”E”]], word = “ABCCED” Output: true … Read more

Function to check if a number is prime?

0 Aadi AhlawatA freelance web developer with a decade of experience in creating high-quality, scalable web solutions. His expertise spans PHP, WordPress, Node.js, MySQL, MongoDB, and e-commerce development, ensuring a versatile approach to each project. Aadi’s commitment to client satisfaction is evident in his track record of over 200 successful projects, marked by innovation, efficiency, … Read more

21. Merge Two Sorted Lists in JavaScript (Leetcode Problem)

0 Problem You are given the heads of two sorted linked lists list1 and list2. Merge the two lists in a one sorted list. The list should be made by splicing together the nodes of the first two lists. Return the head of the merged linked list. Example 1: Input: list1 = [1,2,4], list2 = [1,3,4] Output: [1,1,2,3,4,4] Example 2: Input: … Read more

Find pivot in array where left sum is equal to right sum in JavaScript

0 Solution with n2 complexity Solution with nlogn complexity Solution with 3n (On) complexity Aadi AhlawatA freelance web developer with a decade of experience in creating high-quality, scalable web solutions. His expertise spans PHP, WordPress, Node.js, MySQL, MongoDB, and e-commerce development, ensuring a versatile approach to each project. Aadi’s commitment to client satisfaction is evident … Read more

Guess Number Higher or Lower in JavaScript (Leetcode Problem)

0 We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess. You call a pre-defined API int guess(int num), which returns … Read more

Find  First Bad Version in JavaScript (Leetcode Problem)

0 Problem You are a product manager and currently leading a team to develop a new product. Unfortunately, the latest version of your product fails the quality check. Since each version is developed based on the previous version, all the versions after a bad version are also bad. Suppose you have n versions [1, 2, …, n] and you … Read more

Search Insert Position in JavaScript (Leetcode problem)

0 Problem Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. You must write an algorithm with O(log n) runtime complexity. Example 1: Input: nums = [1,3,5,6], target = 5 Output: 2 Example … Read more

Binary tree postorder traversal in JavaScript

0 Problem Given the root of a binary tree, return the postorder traversal of its nodes’ values. Example 1: Input: root = [1,null,2,3] Output: [3,2,1] Solution Aadi AhlawatA freelance web developer with a decade of experience in creating high-quality, scalable web solutions. His expertise spans PHP, WordPress, Node.js, MySQL, MongoDB, and e-commerce development, ensuring a versatile approach to each … Read more

Binary tree preorder traversal in JavaScript

0 Problem Given the root of a binary tree, return the preorder traversal of its nodes’ values. Example 1: Input: root = [1,null,2,3] Output: [1,2,3] Solution Aadi AhlawatA freelance web developer with a decade of experience in creating high-quality, scalable web solutions. His expertise spans PHP, WordPress, Node.js, MySQL, MongoDB, and e-commerce development, ensuring a versatile approach to … Read more

Skip to content