Shubham Vora

Shubham Vora

793 Articles Published

Articles by Shubham Vora

Page 13 of 80

Maximum count of unique index 10 or 01 substrings in given Binary string

Shubham Vora
Shubham Vora
Updated on 05-Oct-2023 253 Views

In this problem, we will count the maximum number of 10 and 01 pairs that can be formed using the given binary string. To solve the problem, we can check the number of 10 and 01 pairs we can form using adjacent characters without sharing any characters in two pairs. Problem Statement We have given a bin_str binary string. We need to count the maximum number of 10 and 01 pairs we can make using the adjacent characters only. Also, we can use one character in any single pair. Two pairs can't share a single character. Sample Examples Input ...

Read More

C++ Program to Find the Mth element of the Array after K left rotations

Shubham Vora
Shubham Vora
Updated on 05-Oct-2023 169 Views

In this problem, we need to print the element from the given index after rotating the array for K times. This problem teaches us to find the element from the particular index in the rotational array. At first sight, the solution that comes to mind is that rotate the array for K times and access the Mth element, but we will also learn to access the Mth element in the rotational array without rotating the array. Problem Statement We have given arr[] array containing N numbers. Also, we have given the positive integer M and K. We need to rotate ...

Read More

Java Program to Find the Mth element of the Array after K left rotations

Shubham Vora
Shubham Vora
Updated on 05-Oct-2023 300 Views

In this problem, we will rotate the array by K left rotations and find the Mth element in the rotated array. The naïve approach to solve the problem is to rotate the array by K left rotation and take the element from the M – 1 index. The optimized approach is to find the final index value in such a way that the final index is the M – 1 index of the rotated array. Problem Statement We have given a nums[] array containing the positive integers. We have also given the positive integer K and M. We need ...

Read More

Find index of pair among given pairs with just greater average

Shubham Vora
Shubham Vora
Updated on 05-Oct-2023 164 Views

In this problem, we will find the index value for each pair such that the resultant pair's average value is just greater than the current pair's average value. To solve the problem, we will use the sorting algorithm and binary search technique. We will use a sorting algorithm to sort the array based on the pair's average value and a binary search algorithm to search a pair with a greater average value from the sorted array. Problem Statement We have given a pairs[] array containing the N pairs of positive integers. It is also given that the first element of ...

Read More

Count unique Strings by replacing Consonant with closest vowel and vice versa

Shubham Vora
Shubham Vora
Updated on 05-Oct-2023 194 Views

In this problem, we will count the number of unique strings we can generate by replacing each vowel with the closest consonant and each consonant with the closest vowel. We can find the number of choices for each character of the string to replace the current character with other characters. After that, we can multiply the number of choices of each character to get the answer. Problem Statement We have given an alpha string. We need to count the total number of different strings we can generate from the given string by performing the below operations on each character of ...

Read More

Can String be considered as a Keyword?

Shubham Vora
Shubham Vora
Updated on 05-Oct-2023 344 Views

Keywords are important in any programming language, as they are reserved words with a particular predefined meaning. The keywords are used to define the variables, function, and class, change the program's control flow, traverse the list, etc. When we talk about the 'String', it is a fundamental data type to represent a series of characters. Some programming languages refer to the 'String' as a class, and some programming languages refer to the 'String' as a keyword. In this tutorial, we will explore the use of the 'String' word in the programming language. C/C++ The C or C++ programming languages are ...

Read More

How to sort strings in JavaScript?

Shubham Vora
Shubham Vora
Updated on 14-Sep-2023 28K+ Views

The sorting string is to arrange strings in the dictionary or alphabetical order. It is usual to sort the array of strings while developing applications using JavaScript. In this tutorial, we will learn to sort strings in JavaScript. For example, string sorting is very useful here if you got some data from the API and want to show that data in the sorted order. Here, we will learn to sort strings using the built-in methods and various naïve approaches. Use the sort() method to sort strings In JavaScript, sort() is the built-in method we can use with the array. Generally, ...

Read More

Extract a number from a string using JavaScript

Shubham Vora
Shubham Vora
Updated on 14-Sep-2023 37K+ Views

In JavaScript, there are multiple ways to extract a number from a string. One way is to use the match() method and a regular expression to search for all numeric digits in the string. Another way is to use the replace() method and a regular expression to remove all nonnumeric characters from the string, leaving only the numbers. Let’s understand each of the methods with the help of some examples. Using the match() method and regular expression The regular expression is one kind of search pattern which we can create by combining multiple alphabetic and special characters. We can ...

Read More

How to format strings in TypeScript?

Shubham Vora
Shubham Vora
Updated on 14-Sep-2023 53K+ Views

In this tutorial, we will learn to format the strings in TypeScript. The string is the sequence of characters in any programming language, and the same goes for TypeScript. In TypeScript, strings are immutable. The meaning of the immutable is that we can’t change the string character at the particular index, but we can append the character to the string. Below, we will learn different methods to format the string in TypeScript. Using the + operator to merge two or more strings Generally, the '+' operator performs the addition operation of two or more numbers. When we use the + ...

Read More

How to pass an object as a parameter in JavaScript function?

Shubham Vora
Shubham Vora
Updated on 13-Sep-2023 34K+ Views

In this tutorial, we will learn how to pass an object as a parameter in a JavaScript function. One of JavaScript's data types is represented by the Object type. It is used to store keyed collections as well as more complex entities. The Object() function Object()or the object initializer / literal syntax can be used to create objects. Almost all JavaScript objects are instances of Object; a typical object inherits properties (including methods) from Object.prototype, though these properties may be shadowed (a.k.a. overridden). Following are the methods used to pass an object as a parameter in a JavaScript function. Using the ...

Read More
Showing 121–130 of 793 articles
« Prev 1 11 12 13 14 15 80 Next »
Advertisements