Shubham Vora has Published 962 Articles

How to pad a number with leading zeros in JavaScript?

Shubham Vora

Shubham Vora

Updated on 06-Sep-2023 10:20:39

56K+ Views

In this tutorial, we will learn how to pad a number with leading zeros in JavaScript. Padding a number can be done in different ways in JavaScript. In this tutorial, we will see the two most popular ways of doing it − Using the String padStart() method Using the ... Read More

How to determine if a number is odd or even in JavaScript?

Shubham Vora

Shubham Vora

Updated on 02-Sep-2023 15:30:06

40K+ Views

In this tutorial, let’s see how to determine whether a number is odd or even using JavaScript. The first step is understanding the logic. What are even numbers? Even numbers will be exactly divisible by 2. The remainder will be zero. What are odd numbers? Odd numbers will carry a ... Read More

How to stop refreshing the page on submit in JavaScript?

Shubham Vora

Shubham Vora

Updated on 02-Sep-2023 11:31:26

76K+ Views

In this tutorial, we shall learn to stop form refreshing the page on submitting in JavaScript. Let’s cover the methods to accomplish this objective. Using event.preventDefault() to stop page refresh on form submit In this section, we will see how to use event.preventDefault() to stop page refresh on form submission. ... Read More

Maximum number of Strings with Common Prefix of length K

Shubham Vora

Shubham Vora

Updated on 31-Aug-2023 18:22:33

102 Views

In this problem, we need to count the maximum string having common prefix of length K. We can take prefix of length K from all strings and count maximum number of similar prefix using the map data structure. Also, we can use the Trie data structure to solve the problem. ... Read More

Maximize value of Palindrome by rearranging characters of a Substring

Shubham Vora

Shubham Vora

Updated on 31-Aug-2023 18:18:39

111 Views

In this problem, we need to find the maximum palindromic string by rearranging the characters of any substring of the given string. We will use bitmasking to solve the largest palindromic substring. If any substring has bitmasking 0, it contains all characters even a number of times. So, we ... Read More

How to validate ISIN using Regular Expressions?

Shubham Vora

Shubham Vora

Updated on 31-Aug-2023 10:05:54

466 Views

In this problem, we will use the regular expression to validate the ISIN number in C++. The ISIN stands for the International Securities Identification Number. It is a unique code to identify stocks, financial bonds, etc. The length of the ISIN number can be 12 or 14, which provides international ... Read More

Find the final String by incrementing prefixes of given length

Shubham Vora

Shubham Vora

Updated on 31-Aug-2023 09:20:34

69 Views

In this problem, we need to increase each character of multiple prefixes of size given in the array. The naïve approach to solving the problem is to take each prefix of the size given in the array and increment each character of the prefix by 1. The best approach is ... Read More

Substring with maximum ASCII sum when some ASCII values are redefined

Shubham Vora

Shubham Vora

Updated on 29-Aug-2023 19:18:50

85 Views

In this problem, we will find the substring of the given string whose character's ASCII value's sum is maximum when we redefine the ASCII values. The naïve approach to solve the problem is to find the sum of all substring's character's ASCII value and get the substring having maximum ... Read More

Python Program for Convert characters of a string to opposite case

Shubham Vora

Shubham Vora

Updated on 29-Aug-2023 19:14:16

262 Views

In this problem, we will toggle the case of each string character. The easiest way to toggle the case of each string character is using the swapcase() built-in method. Also, we can use the ASCII values of the characters to swap their case. Python also contains isUpper() and isLower() ... Read More

Minimize Suffix flip to make Binary String non decreasing

Shubham Vora

Shubham Vora

Updated on 29-Aug-2023 19:12:16

85 Views

In this problem, we will count the number of minimum operations required to convert string non-decreasing order by flipping the characters of the binary string. We can flip all characters of the substring starting from the \mathrm{p^{th}} index if the character at the pth index is 0 and not ... Read More

Previous 1 ... 4 5 6 7 8 ... 97 Next
Advertisements