The N number is the special number of integer type that calculates the individual digit of sum. So, this sum will be divisible by its own number. Let’s take an example of this. The given integer number, N = 36 The sum of each digit, 3 + 6 = 9 Therefore, 36 is successfully divisible by 9 and it verifies for N divides it. Algorithm The following steps are- Step 1: We will start the program by mentioning the header file iostream. Step 2: Common Matches:- Then used the function definition digit_sum() that accepts the parameter a variable n ... Read More
Python’s Pandas DataFrame defines the two-dimensional structure that consists of rows and columns. The main feature of pandas is an easier way of handing the given data. In Python, we have some in-built functions such as to_datetime(), sorted(), lambda, and, sort_value() will be Sort a Pandas DataFrame by Date. Syntax The following syntax is used in the examples- to_datetime() The to_datetime() is an in-built function in Python that convert string dates into date-time objects. sorted() The built-in function sorted() of Python states that the list can be sort as specified iterable objects. lambda This lambda function in ... Read More
The problem statement allows us to determine the position of the desired string in the list, which can be useful for various purposes, such as accessing or manipulating elements at that specific index. In Python, we have some built-in functions like reduce(), str(), filter(), lambda, and, all() that will be used to Find Index Containing String in List. Syntax The following syntax is used in the examples- reduce() This function is defined under the functools module str() This is a built-in method in Python that can convert the specified value into a string. filter() The ... Read More
A sentence is a group of words that are present in a string. In this problem statement, we need to set a specific word and check whether the word is present in a given string or not. In C++, we have some pre-defined functions such as find(), npos(), and istringstream() will be used to Check if a word is present in a sentence. Using Standard library Function The program uses a standard library function that allows the programmer to use pre-existing functions of the C compiler such as find() and npos() to perform certain tasks. Syntax The following syntax is ... Read More
The palindrome refers to same number when the digits are reversed. In this program, we need to set the condition and operation based on an even number of digits to identify whether the given input satisfied for palindrome or not. In C++, we have STL(Standard template library) functions such as to_string(), length(), rbegin(), rend(), and, push_back() will be used to Check if a number with an even number of digits is palindrome or not. For example- 2662, 42124, 44, 888, etc are satisfied for even digit palindrome numbers. Using for loop and if-else statement The program uses for loop to ... Read More
PHP: PHP (Hypertext Preprocessor) is a widely-used open-source server-side scripting language that is specifically designed for web development. It was originally created by Rasmus Lerdorf in 1994 and has since evolved into a powerful language used by millions of developers worldwide. PHP is primarily used to develop dynamic web pages and web applications. It allows developers to embed PHP code within HTML, making it easy to mix server-side logic with the presentation layer. PHP scripts are executed on the server, and the resulting HTML is sent to the client's browser. To test a URL for a 404 error ... Read More
The term dictionary Mesh is defined by storing the value pair of every key set to dictionary. To include the K list in the dictionary means to insert the list as value pair. In Python, we have some built-in functions such as defaultdict() and lambda will be used to solve the K list dictionary Mesh. Let’s take an example of this. Given input list, list1 = [10, 20, 30] list2 = [40, 50] The final output becomes: {10: {40: [], 50: []}, 20: {40: [], 50: []}, 30: {40: [], 50: []}} Syntax The following syntax is used ... Read More
In this problem, we need to find all missing binary strings of length N from the array. We can solve the problem by finding all permutations of a binary string of length N and checking which permutations are absent in the array. Here, we will see iterative and recursive approaches to solve the problem. Problem statement – We have given an array arr[] of different lengths containing the binary strings of length N. We need to find all the missing binary strings of length N from the array. Sample examples Input – arr = {"111", "001", "100", "110"}, N = ... Read More
In this problem, we need to count the total number of substrings of string str containing exactly K distinct vowels. We can solve the problem in two different ways. The first approach is to traverse all substrings and count the number of vowels in each substring. We can also use the map data structure to optimize the code of the first approach. Problem statement – We have given string str of length N. The string contains uppercase and lowercase alphabetical characters. Also, we have given integer K. We need to find the total number of substrings of str containing exactly ... Read More
In this problem, we need to find a total number of substrings of length K containing exactly K vowels. We will see two different approaches to solving the problem. We can use a naïve approach that checks the number of vowels in each substring of length K. Also, we can use the sliding window approach to solve the problem. Problem statement – We have given a string str of length N containing lowercase and uppercase alphabetical characters. We need to count the total number of substrings of length K which contains exactly X vowels. Sample examples Input– str = ... Read More