Hafeezul Kareem has Published 344 Articles

Find trace of matrix formed by adding Row-major and Column-major order of same matrix in C++ Program

Hafeezul Kareem

Hafeezul Kareem

Updated on 29-Dec-2020 10:34:15

321 Views

In this tutorial, we are going to write a program that finds trace of matrix formed by row and column major matrices.Let's see how to form a row and column major matrices when order of the matrix is given.Order − 3 x 3Row Major Matrix −123456789Column Major Matrix −147258369We have ... Read More

Find total number of distinct years from a string in C++ Program

Hafeezul Kareem

Hafeezul Kareem

Updated on 29-Dec-2020 10:32:04

521 Views

In this tutorial, we are going to write a program that finds distinct years in the given string. Let's see some examples. We are assuming the date format is DD/MM/YYYY.Input − Sample example with dates 01/11/2020, 02/12/2020, and 03/10/2019.Output − 2We have two distinct years in the given text 2020 ... Read More

Find time taken for signal to reach all positions in a string - C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 29-Dec-2020 10:30:07

80 Views

In this tutorial, we are going to write a program that computes the time taken for a signal to reach all positions in a string. Let me explain it with an example.We will have a string that contains only s and p characters. s is a signal and p is ... Read More

Find three integers less than or equal to N such that their LCM is maximum - C++

Hafeezul Kareem

Hafeezul Kareem

Updated on 29-Dec-2020 10:27:54

342 Views

In this tutorial, we are going to write a program that is based on the concepts of LCM. As the title says, we have to find three numbers that are less than or equal to the given number whose LCM is maximum.Let's see an example.Before diving into the problem let's ... Read More

Python - Inserting item in sorted list maintaining order

Hafeezul Kareem

Hafeezul Kareem

Updated on 13-Nov-2020 19:17:11

7K+ Views

In this article, we are going to learn how to insert an item in a sorted list maintaining the order. Python has a built-in module called bisect that helps us to insert any element in an appropriate position in the list.Follow the below steps to write the code.Import the module ... Read More

Python - Intersect two dictionaries through keys

Hafeezul Kareem

Hafeezul Kareem

Updated on 13-Nov-2020 19:13:25

1K+ Views

In this article, we are going to learn how to intersect two dictionaries using keys. We have to create a new dictionary with common keys. Let's see an example.Input: dict_1 = {'A': 1, 'B': 2, 'C': 3} dict_2 = {'A': 1, 'C': 4, 'D': 5} Output: {'A': 1, 'C': ... Read More

Python - Intersection of multiple lists

Hafeezul Kareem

Hafeezul Kareem

Updated on 13-Nov-2020 19:08:20

897 Views

In this article, we are going to see how to intersect two lists that contain multiple lists in different ways. Let's start in the traditional way.Follow the below the steps to solve the problemInitialize two lists with multiple listsIterate over the first list and add the current item in the ... Read More

Python - Intersection of two String

Hafeezul Kareem

Hafeezul Kareem

Updated on 13-Nov-2020 19:02:25

3K+ Views

In this article, we are going to learn how to intersect two strings in different ways.Follow the below the steps to solve the problem.Initialize two strings and an empty string.Iterate over the first string and add the current character to the new string if it presents in the second string ... Read More

Python - Join tuple elements in a list

Hafeezul Kareem

Hafeezul Kareem

Updated on 13-Nov-2020 18:56:17

10K+ Views

In this article, we are going to learn how to join tuple elements in a list. It's a straightforward thing using join and map methods. Follow the below steps to complete the task.Initialize list with tuples that contain strings.Write a function called join_tuple_string that takes a tuple as arguments and ... Read More

Python - Joining only adjacent words in list

Hafeezul Kareem

Hafeezul Kareem

Updated on 13-Nov-2020 18:52:49

243 Views

In this article, we are going to learn how to join adjacent words in a list, not digits. Follow the below steps to solve the problem.Initialize the list.Find the words that are not digits using isalpha method.4Join the words using join method.Add all the digits at the end by finding ... Read More

Advertisements