Sudhir sharma has Published 1206 Articles

Prime Factorization using Sieve O(log n) for multiple queries in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2021 05:07:35

2K+ Views

In this problem, we need to create a program to calculate Prime Factorization using Sieve O(log n) for multiple queries. As the general method takes O(sqrt(n) ) time which will increase the time required to a huge extent from multiple queries.Let’s recap first, Prime factorization of a number includes ONLY the ... Read More

Principles of Risk Management and Paradigm in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2021 05:03:15

599 Views

Risk Management is the approach that is used to manage all available resources and make the best use of the resources available in the system.The project manager will analyse risks from all categories and there might be some risks in the working of the project in the runtime environment.Principles of Risk ManagementThere ... Read More

Print a number as string of 'A' and 'B' in lexicographic order in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2021 05:00:50

74 Views

In this problem, we are given a number N. Our task is to create a program to Print a number as string of ’A’ and ‘B’ in lexicographic order. Representation of all numbers as string of ‘A’ and ‘B’ is1 = A 2 = B 3 = AA 4 = AB 5 = BA 6 = ... Read More

Print all longest common sub-sequences in lexicographical order in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2021 05:00:17

593 Views

In this problem, we are given two string str1 and str2. Our task is to create a program to Print all longest common subsequences in lexicographical order. Let’s take an example to understand the problem,  Input: str1 = “gfare” ,  str2 = “rfare”Output: fareSolution ApproachIn this problem, we will find all possible longest ... Read More

Sum of the series 1 + (1+3) + (1+3+5) + (1+3+5+7) + ...... + (1+3+5+7+...+(2n-1)) in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2021 04:59:42

462 Views

In this problem, we are given a number n. Our task is to create a program to find the sum of series 1 + (1+3) + (1+3+5) + (1+3+5+7) + …… + (1+3+5+7+…+(2n-1)). Let’s take an example to understand the problem,  Input:   n = 5Output:  55So, according to the question ... Read More

Sum over Subsets - Dynamic Programming in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2021 04:59:09

219 Views

In this problem, we are given an array arr[] of size 2n. Our task is to create a program to find the sum over subset using dynamic programming to solve it.We need to calculate function, F(x) = Σ Ai such that x&i == i for all x. i.e. i is ... Read More

Sum of XOR of sum of all pairs in an array in C++

sudhir sharma

sudhir sharma

Updated on 27-Jan-2021 04:57:57

1K+ Views

In this problem, we are given an array arr[] of size n. Our task is to create a program to find the sum of XOR of sum of all pairs in an array.Let’s see an example to understand the problem,  Input: arr[5, 7, 9]Output: 22Explanation: (5+5) ^ (5+7) ^ (5+9) ^ (7+5) ^ ... Read More

Print all possible ways to convert one string into another string in C++

sudhir sharma

sudhir sharma

Updated on 25-Jan-2021 05:29:05

169 Views

In this problem, we are given two strings str1 and str2. Our task is to create a program to Print all possible ways to convert one string into another string. Problem Description: Here, we need to find all possible ways using which we can convert str1 to str2. While converting, we can perform ... Read More

Print BST keys in given Range - O(1) Space in C++

sudhir sharma

sudhir sharma

Updated on 25-Jan-2021 05:28:31

81 Views

In this problem, we are given two values k1 and k2 (k1 < k2), and the root of the binary search tree. Our task is to create a program to Print BST keys in given Range. Problem Description: We will print all the keys of the tree from n1 to n2 in ... Read More

Print cells with same rectangular sums in a matrix in C++

sudhir sharma

sudhir sharma

Updated on 25-Jan-2021 05:28:12

74 Views

In this problem, we are given a matrix mat of size mXn of integer values. Our task is to create a program to Print cells with same rectangular sums in a matrix.Problem description: We will be finding a cell in the matrix in such a way that the sum of sub-matrices ... Read More

Advertisements