popoff
BAN USER- 0of 0 votes
AnswersDo zigzag level order traversal of a BST
- popoff in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
AnswersFind the nodes at d distance from a certain node in a Binary Tree
- popoff in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm - 0of 0 votes
AnswersFind the largest number obtained by rearranging the digits in O(n) time.
- popoff in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 0of 0 votes
Answerswrite a function to determine if a string contains a repeated sequence
- popoff in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer - 1of 1 vote
Answerswrite a function to rotate an m x n array by 90 degrees
- popoff in India| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Arrays
- 0 Answers Find the highest number after rearranging digits
Do it in O(n) time
- popoff January 01, 2013| Flag | PURGE
void printPair(int arr[],int size,int sum)
{
map<int,int> traversed;
map<int,int>::iterator it;
int i , remain;
for (i = 0 ; i < size ; i++)
{
remain = sum - arr[i];
it = traversed.find(remain);
if (it != traversed.end() && it->second > 0)
{
cout << "\n(" << it->first << "," << arr[i] << ")" ;
traversed.erase(it);
}
if(it != traversed.end())traversed[arr[i]]=1;
else (it->second)++
}
}
Let me reiterate the question :
It was to find out if a string contains an adjacent repeated sequence of characters.
For Ex1 : 123123 : this contains a repeated adjacent sequence which is 123
Ex2 : 123xy123 : this does not contain a repeated adjacent sequence so answer would be false.
For the example mentioned by you , yes it would have a repeated sequence which is p
Let me clarify few things here -
1. Big companies can ask simple questions.They have done it in the past and they are already doing it.
2. Questions posted here are just to give an idea about what is being asked these days and not about finding solution.
3. I was able to solve it and also knewing the solution...but I didn't wrote the solution because it was really too simple.
Nice Solution
- popoff August 30, 2014