karthikkamal666
BAN USER- 2of 2 votes
AnswersK largest elements from a big file or array.
- karthikkamal666 in India| Report Duplicate | Flag | PURGE
Algorithm - -2of 2 votes
AnswersGiven an integer Q and an array A of size N, can we figure out the answer to each of the Q queries?
- karthikkamal666 in India
Each query contains two integers x and y, and we need to find whether the value find(x,y) is odd or even:
find(int x,int y)
{
if(x>y) return 1;
ans = pow(A[x],find(x+1,y));
return ans;
}
Here pow(a,b)=ab.
Example: Let N=3, the array be [3,2,7], and the query be x=1 and y=2. Now do find(1,2)=9, which is odd so answer is odd.
I know the basic approach, but what if queries can be as large as 105 and same is with N?
Its given that 1≤x, y≤N, and x≤y| Report Duplicate | Flag | PURGE
Math & Computation - 0of 0 votes
Answersremove a character in a string to make palindrome?
- karthikkamal666 in United States| Report Duplicate | Flag | PURGE
Algorithm - 1of 1 vote
Answersfind the minimum number of swaps to convert one string into another ?ex:kamal amalk
- karthikkamal666 in India| Report Duplicate | Flag | PURGE
no other operation other than swap
- karthikkamal666 May 15, 2014we can swap arbitary two characters
ex:kamal amalk
ans:3
numbers are not negative,numbers in array ranging from 1<=n<=9
- karthikkamal666 June 17, 2014