#include using namespace std; string findSum(string str1, string str2){ if (str1.length() > str2.length()) swap(str1, str2); string str = “”; int n1 = str1.length(); int n2 = str2.length(); reverse(str1.begin(), str1.end()); reverse(str2.begin(), str2.end()); int carry = 0; for (int i = 0; i < n1; i++) { int sum = ((str1[i] - '0') + (str2[i] - '0') + carry); str.push_back(sum % 10 + '0'); carry = sum / 10; } for (int i = n1; […]

Continue ReadingGiven three integers A, N and P, the task is to find (A^(N!)) % P.Examples:Input: A = 2, N = 1, P = 2Output: 0Explanation: As (2^(1!)) = 2Therefore 2 % 2 will be 0.Input: A = 3, N = 3, P = 2Output: 1Naive Approach: The simplest solution of this problem can be find […]

Continue Reading#include using namespace std; void merge(vector& v, int left, int mid, int right, int& inversions){ vector temp(right – left + 1); int i = left; int j = mid + 1; int k = 0; int cnt = 0; while (i

Continue Reading