36. Valid Sudoku using JavaScript

0 Problem Determine if a 9 x 9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: Note: Example 1: Input: board = [[“5″,”3″,”.”,”.”,”7″,”.”,”.”,”.”,”.”] ,[“6″,”.”,”.”,”1″,”9″,”5″,”.”,”.”,”.”] ,[“.”,”9″,”8″,”.”,”.”,”.”,”.”,”6″,”.”] ,[“8″,”.”,”.”,”.”,”6″,”.”,”.”,”.”,”3″] ,[“4″,”.”,”.”,”8″,”.”,”3″,”.”,”.”,”1″] ,[“7″,”.”,”.”,”.”,”2″,”.”,”.”,”.”,”6″] ,[“.”,”6″,”.”,”.”,”.”,”.”,”2″,”8″,”.”] ,[“.”,”.”,”.”,”4″,”1″,”9″,”.”,”.”,”5″] ,[“.”,”.”,”.”,”.”,”8″,”.”,”.”,”7″,”9″]] Output: true Example 2:Input: board = [[“8″,”3″,”.”,”.”,”7″,”.”,”.”,”.”,”.”] ,[“6″,”.”,”.”,”1″,”9″,”5″,”.”,”.”,”.”] ,[“.”,”9″,”8″,”.”,”.”,”.”,”.”,”6″,”.”] ,[“8″,”.”,”.”,”.”,”6″,”.”,”.”,”.”,”3″] ,[“4″,”.”,”.”,”8″,”.”,”3″,”.”,”.”,”1″] ,[“7″,”.”,”.”,”.”,”2″,”.”,”.”,”.”,”6″] ,[“.”,”6″,”.”,”.”,”.”,”.”,”2″,”8″,”.”] ,[“.”,”.”,”.”,”4″,”1″,”9″,”.”,”.”,”5″] ,[“.”,”.”,”.”,”.”,”8″,”.”,”.”,”7″,”9″]] Output: false Explanation: Same as … Read more

238. Product of Array Except Self

0 Problem Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i]. The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer. You must write an algorithm that runs in O(n) time and without using the division operation. Example 1:Input: nums = [1,2,3,4] Output: [24,12,8,6] Example 2:Input: nums = [-1,1,0,-3,3] … Read more

347. Top K Frequent Elements

0 Problem Given an integer array nums and an integer k, return the k most frequent elements. You may return the answer in any order. Example 1:Input: nums = [1,1,1,2,2,3], k = 2 Output: [1,2] Example 2:Input: nums = [1], k = 1 Output: [1] Constraints: Solution First attempt : (Can be optimized further) Optimized solution: Aadi AhlawatA freelance web developer with … Read more

49. Group Anagrams

0 Problem Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Example 1:Input: strs = [“eat”,”tea”,”tan”,”ate”,”nat”,”bat”] Output: [[“bat”],[“nat”,”tan”],[“ate”,”eat”,”tea”]] Example 2:Input: strs = [“”] Output: [[“”]] Example … Read more

217. Contains Duplicate

0 Problem Given an integer array nums, return true if any value appears at least twice in the array, and return false if every element is distinct. Example 1:Input: nums = [1,2,3,1] Output: true Example 2:Input: nums = [1,2,3,4] Output: false Example 3:Input: nums = [1,1,1,3,3,4,3,2,4,2] Output: true Constraints: Solution First attempt : (Can be optimized further) Aadi AhlawatA freelance web developer … Read more

242. Valid Anagram

0 Problem Given two strings s and t, return true if t is an anagram of s, and false otherwise. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Example 1:Input: s = “anagram”, t = “nagaram” Output: true Example 2:Input: s = “rat”, t = “car” Output: false Constraints: … Read more

Permutations and Combinations in Data Structures and Algorithms with JavaScript

0 In the realm of Data Structures and Algorithms (DSA), permutations and combinations play a crucial role. They are fundamental concepts in combinatorics and have wide-ranging applications in computer science, particularly in DSA. Permutations A permutation is an arrangement of all the members of a set into some sequence or order. The number of permutations … Read more

Choose domain name

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

20. Valid Parentheses Leetcode solution in JavaSctipt (js)

0 Problem Given a string s containing just the characters ‘(‘, ‘)’, ‘{‘, ‘}’, ‘[‘ and ‘]’, determine if the input string is valid. An input string is valid if: Example 1: Input: s = “()” Output: true Example 2: Input: s = “()[]{}” Output: true Example 3: Input: s = “(]” Output: false Constraints: Solution Aadi AhlawatA freelance web developer with a decade … Read more

Skip to content