Prabhdeep Singh

Prabhdeep Singh

161 Articles Published

Articles by Prabhdeep Singh

Page 5 of 17

Explain Chosen and Select2 with Examples

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 1K+ Views

Select2 and Chosen are popular jQuery plugins that enhance HTML select boxes with improved styling, search capabilities, and user-friendly features. Both plugins work with single and multiple select elements, making form interactions more intuitive. Chosen Plugin Chosen is a JavaScript plugin that transforms standard select boxes into user-friendly dropdown interfaces. It's available for both jQuery and Prototype frameworks. Key Features of Chosen User-friendly Interface Users can search by typing instead of scrolling through long lists. Matching is instant, and non-matching options are filtered out automatically. Progressive Enhancement Chosen gracefully degrades to standard HTML select elements ...

Read More

Explain Implement a Memoization Helper Function

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 435 Views

Memoization is a programming technique that improves function performance by caching previously calculated results. When a function is called with the same arguments, instead of recalculating, it returns the cached result, significantly reducing execution time for expensive operations. What is Memoization? Memoization works by storing function results in a cache (usually an object or Map). When the function is called again with identical parameters, it checks the cache first. If the result exists, it returns the cached value; otherwise, it calculates the result and stores it for future use. Basic Example: Slow Function Without Memoization Let's ...

Read More

JavaScript Program to check idempotent matrix

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 239 Views

An idempotent matrix is a square matrix that has the same number of rows and columns and when we multiply the matrix by itself the result will be equal to the same matrix. We will be given a matrix and we have to find that whether it is an idempotent matrix or not. Mathematical Definition If the given matrix is M, then for M to be an idempotent matrix it should follow the property: M * M = M Matrix Multiplication Overview Multiplication of a matrix with another matrix produces another matrix and ...

Read More

JavaScript Program to Check if a Given Matrix is Sparse or Not

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 357 Views

To check if a given matrix is sparse or not, we will be discussing two different approaches, their complexities, and example codes. A sparse matrix is a special type of matrix in which the number of zeroes is strictly more than half of the total number of elements present in the given matrix. In this article we are having a 2D matrix, our task is to write a JavaScript program to check if a given matrix is sparse or not. Users must be familiar with conditional statement, nested for loop and javascript methods. Example Input: Matrix: [[1, ...

Read More

JavaScript Program to Check if a Matrix is Symmetric

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 793 Views

A symmetric matrix is a square matrix that equals its transpose, meaning element at position (i, j) equals element at position (j, i). In mathematical terms, A = AT, where A is the matrix and AT is its transpose. In this article, we'll explore JavaScript programs to check if a given matrix is symmetric using different approaches. Original Matrix A 1 ...

Read More

JavaScript Program to Check If a Singly Linked List is Palindrome

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 376 Views

A singly linked list is a linear data structure that is stored in a non-contiguous way in the memory and each block is connected by holding the address of the next block also known as a node. A palindrome can be explained as a set of characters, digits, etc, and it reads the same from both the front and backside. We will be given a singly linked list and have to find whether the values stored at the nodes are equal from both the front and backside. Problem Examples Input 1 -> 2 -> 3 -> 3 ...

Read More

JavaScript Program for Ceiling in a sorted array

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 282 Views

An array is a linear data structure that contains objects, and in a sorted array, elements are arranged in increasing order. Given a sorted array and an integer x, we need to find the ceiling of x. The ceiling is the smallest element in the array that is greater than or equal to x. If no such element exists, we return that the ceiling does not exist. Problem Understanding Let's understand this with examples: Example 1 Array = [1, 3, 5, 7, 9] X = 19 Output: Ceiling does not exist (no element ≥ ...

Read More

JavaScript Program for Check if an array is sorted and rotated

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 363 Views

A sorted array is an array where all the elements are present in increasing order. We have given an array of size N and an array containing the distinct integers (which means every integer is present only one time). We have to check the array is sorted and rotated in a clockwise direction. Here we have to return 'YES' if the array is sorted and rotated otherwise, we have to return 'NO'. Note − Here we are talking about the sorted and rotated means at least one rotation should be present. We cannot consider a sorted array as a ...

Read More

JavaScript Program for the Last duplicate element in a Sorted Array

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 506 Views

In this article, we are going to explore a JavaScript program that works with a sorted array containing duplicate elements. The task is to traverse the array using a loop and identify both the index of the last duplicate element and the duplicate number. Introduction to Problem In the given problem we have to find the last duplicate element in a sorted array. Duplicate means the number is present more than one time. Example − Input arr[] = {1, 2, 2, 3, 5, 5, 6, 7} Output Last index: 5 Last duplicate ...

Read More

JavaScript Program for the Least Frequent Element in an Array

Prabhdeep Singh
Prabhdeep Singh
Updated on 15-Mar-2026 777 Views

In this program, we are given an array of integers and need to return the element that appears the least number of times. If multiple elements have the same minimum frequency, we can return any one of them. Problem Statement Given an array with duplicate numbers, we need to count the occurrence of each element and return the one with the least frequency. If multiple elements have the same minimum frequency, any one can be returned. Example 1: Input: [1, 3, 3, 5, 5, 4, 4, 4] Output: 1 Explanation: 1 appears 1 time, 3 ...

Read More
Showing 41–50 of 161 articles
« Prev 1 3 4 5 6 7 17 Next »
Advertisements