novicedhunnu
BAN USER 0of 0 votes
AnswersYou are a string conscious guy. You categorise strings into 3 types: good, bad, mixed. If a string has 3 consecutive vowels or 5 consecutive consonants or both, it is bad. Else it is good. If a string has ‘?’, that can be replaced with any character. Thus, string ‘?aa’ can be bad if ‘?’ is vowel or good if consonant. Thus, it is mixed. Implement function which takes string s as input and returns good, bad or mixed
 novicedhunnu in India Report Duplicate  Flag  PURGE
Adobe SDE1 Algorithm  0of 0 votes
AnswersYou are a musician who plays different songs at different volumes. You have a particular difference that needs to be present for new song, but you don't care if it is more or less. You are given initial volume l, array of volume changes where arr[i] is volume change required after ith song, max_vol h (min vol always 0), array size n. You need to find the max possible volume for the last song. But if at any point change is not possible, return 1. Format: n, arr[n], l, h. Ex: 3, 1 1 1, 0, 5. Ans: 3. Ex: 4, 9 1 5 4, 8, 15. Ans: 1. Ex: 3, 5 3 7, 5, 10. Ans: 10.
 novicedhunnu in India
Input explanation :
First number = size of array,
then next ‘n’ numbers of array.
Then ‘l’ means initial volume
Then ‘h’ means max volume.
Eg. 3, 1 1 1, 0, 5 means n = 3, arr = {1,1,1}, l = 0, h = 5,
Output explanation: initially you play music at vol 0, then for first arr element. Arr[0] inc. by 1,
Arr[1] inc. by 1, arr[2] inc by 1 total = 3 Report Duplicate  Flag  PURGE
Adobe SDE1 Algorithm  1of 1 vote
AnswersA list of words is given and a bigger string given how can we find whether the string is a permutation of the smaller strings.
 novicedhunnu in India
eg s= badactorgoodacting dict[]={'actor','bad','act','good'] FALSE
eg s= badactorgoodacting dict[]={'actor','bad','acting','good'] TRUE
The smaller words themselves don't need to be permuted. The question is whether we can find a ordering of the smaller strings such that if concatenated in that order it gives the larger string
One more constraint  some words from dict[] may also be left over unused Report Duplicate  Flag  PURGE
Microsoft SDE1 Algorithm  0of 0 votes
AnswersFind the number of columnswaps required to find the largest rectangle of all ones in a matrix.
 novicedhunnu in India for N/A
The question is similar to the one in this link
http://www.geeksforgeeks.org/findthelargestrectangleof1swithswappingofcolumnsallowed/
But we need to find the number of minimum swaps required Report Duplicate  Flag  PURGE
Walmart Labs SDE1  3of 3 votes
AnswersWhat does Innoplexus ask about in the personal interview round for Technical Summer Interns?
 novicedhunnu in India Report Duplicate  Flag  PURGE
N/A Intern
The key here is that for non reduceable fraction the gcd(greatest common divisor) of the numerator and denominator must be 1 or in other words they must be coprime.
int gcd(int a,int b){
if(b==0)
return a;
return gcd(b,a%b);
}
bool isNonReduceableFraction(int numerator,int denominator){
if(gcd(numerator,denominator)==1)
return true;
return false;
}

novicedhunnu
August 14, 2016 #include<bits/stdc++.h>
using namespace std;
int romanToInt(string s){
int res=0;
for(int i=0;i<s.length();++i){
if(s[i]=='L')
res+=50;
else if(s[i]=='X'){
if(i<s.length()1 && (s[i+1]=='L') )
res=10;
else
res+=10;
}
else if(s[i]=='V')
res+=5;
else if(s[i]=='I'){
if(i<s.length()1 && (s[i+1]=='X'  s[i+1]=='V') )
res;
else
res++;
}
}
return res;
}
bool comp(string a,string b){
istringstream isA(a);
istringstream isB(b);
string splitStringA[2],splitStringB[2];
string temp;
int i=0;
while(isA>>temp)
splitStringA[i++]=temp;
i=0;
while(isB>>temp)
splitStringB[i++]=temp;
if(splitStringA[0]<splitStringB[0])
return true;
else if(splitStringA[0]>splitStringB[0])
return false;
else
return romanToInt(splitStringA[1])<=romanToInt(splitStringB[1]);
}
int main(){
string names[6]={"Richard V","Henry VI","Edward II","Richard XXV","Henry IX","Edward LII"};
sort(names,names+6,comp);
for(int i=0;i<6;++i)
cout<<names[i]<<endl;
return 0;
}

novicedhunnu
August 14, 2016 i think a slight modification of the binary search can be used for this purpose in which each time we check if (num>=arr[low])&&(num<=arr[mid]){ high=mid} and so on
 novicedhunnu August 29, 2014
I think I myself have a solution.
 novicedhunnu August 14, 2016Suppose we have to search the phrase "This is".
Then for every occurrence of "This" we will have a node in the trie with the index stored
Then we search for the word "is" in the trie, and hence we can find all the indices in which "is" occur in the large text
Then for each index at which "is" occurs, we can check in O(m+n) time { all the indices at which index of occurrence of "is"  length of("the ") } which matches with the indices at which "the" occurs.
where m,n number of indices at which "the" , "is" occur respectively.
This approach can be extended to phrases with more than two words in this manner
For e.g. we have to search "This is a good approach"
We keep all the indices at which "This is" occurred in a set say S. Then we match all indices at which "a" occurs and match it in the above mentioned manner for all the indices in S and continue so on