Re: [algogeeks] Re: Some adobe interview questions.

2011-07-07 Thread Yogesh Yadav
Q10. array a[]={19 16 18 3 50 70 12 11 14} array b[]; sum required=30 3 11 12 14 16 18 19 50 70 //sort 0 1 2 3 4 5 6 7 8 //index lr count=0,i=0; while(lr) { if(a[l]+a[r])sum r--; elseif(a[l]+a[r])sum l++; else {

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-07 Thread raj singh
thanks yogi. it is amzing tric and solution -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-07 Thread Yogesh Yadav
Q3. start with 7000 //8 digit number 7000 7001 //as 7 is 1 time so 8th place is 1 6001 //as due to 1 on 8th place no. of zeros =6 6010 //as 6 is present so 7th place is 1 and 7 is not present so 8th place is again changed to 0 6110 //as 1 is present on 7th place so at 2nd

[algogeeks] Re: Some adobe interview questions.

2011-07-06 Thread vikas
very nice link for questions of type Q9. http://pw1.netcom.com/~tjensen/ptr/ch9x.htm -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/0ngOncUXrRYJ. To post

[algogeeks] Re: Some adobe interview questions.

2011-07-06 Thread Abhi
Q1. First sort both the strings using counting sort perhaps. Then starting from the first character, search for it in the second string using binary search. The succeeding character of A will be searched from the index in B at which last character of A was found Worst case: When both the

[algogeeks] Re: Some adobe interview questions.

2011-07-06 Thread Abhi
Sol for Q4 int pallindrome(char *str) { static length = strlen(str); if(length 1) return 1; if(str[0] == str[length-1]) { length -= 2; return pallindrome(str+1); } else return 0; } -- You received this message because you are

[algogeeks] Re: Some adobe interview questions.

2011-07-06 Thread yogi
Yes I am also getting the same. On Jul 5, 12:50 am, Ritesh Srivastava riteshkumar...@gmail.com wrote: For Q3 . Sum of all the digits should be 8. I think , 42101000 is an answer. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to

[algogeeks] Re: Some adobe interview questions.

2011-07-06 Thread tiru
what about 7? 7 occurred once right? On Jul 6, 12:32 am, aditya kumar aditya.kumar130...@gmail.com wrote: in 7000 : '0' occurs seven times and rst of the numbers occur zero times. i still dint get where i am wrong . plz explain me . On Wed, Jul 6, 2011 at 12:47 AM, L

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-06 Thread Tushar Bindal
You have given solution for number of coins required for different sum as explained on topcoder tutorial. But I think the question has put forward some conditions based on which it asks us to find the denominations of the 6 coins. You have taken the sum given(which cannot be obtained by using

[algogeeks] Re: Some adobe interview questions.

2011-07-06 Thread yogi
On Jul 5, 4:04 am, Dumanshu duman...@gmail.com wrote: ans1. use counting sort for character array (0 to 255) then check for the second string if same or not. ans2. send 1 and 2, 1 comes back, send 10 and 5, 2 comes back, send 2 and 1 ans3. As vikas said, sum of digits should b 8. In that

[algogeeks] Re: Some adobe interview questions.

2011-07-06 Thread Ankit
For Q1: if length1!=length2 = false else take 2 arrays ch1[256] and ch2[256] For every character c in each string increment the element ch[c] in the respective array; now traverse both arrays together. if each ch1[] element =each ch2[] element = true

[algogeeks] Re: Some adobe interview questions.

2011-07-06 Thread KK
for Q5 change the expr into postfix and then build expression tree... but is expression tree same as parse tree?? correct me if i m wrong!! -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-06 Thread Navneet Gupta
Anyone for Q10, i wonder if it can really be solved in O(n). Very obvious O(nlogn) is what I know On Thu, Jul 7, 2011 at 1:25 AM, KK kunalkapadi...@gmail.com wrote: for Q5 change the expr into postfix and then build expression tree... but is expression tree same as parse tree?? correct me if i

[algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread vikas
My program for Q4. // recursively find if a given string is palindrome bool IsPalindrome(string s, int start, int start2, bool flag) { bool flag1 = flag; if (start = 0 start2 (s.Length)) { char c1 = s[start];

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread Azhar Hussain
Q8 is a DP problem, here is the solution #include stdio.h #define MAX 125 #define VAL 6 int Min[MAX]; int N[VAL] = {5, 10, 20, 25, 50, 100}; int main(void) { int i, j; for (i = 1; i MAX; i++) Min[i] = 100; for (i = 5; i MAX; i += 5) for (j = 0; j VAL; j++)

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread shady
don't give programs.. discuss the logic behind that, algorithms are important.. On Tue, Jul 5, 2011 at 12:43 PM, Azhar Hussain azhar...@gmail.com wrote: Q8 is a DP problem, here is the solution #include stdio.h #define MAX 125 #define VAL 6 int Min[MAX]; int N[VAL] = {5, 10, 20,

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread udit sharma
Q-8: 50,25,10,10,10,10 Q2-: Let A,B,C and D are the persons suct tat A takes 1min, B-2, C-5 and D-10 * A and B go across 2 minutes A goes back with light 1 minute C and D go across 10 minutes B goes back with light 2 minute A and

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread piyush jain
q2.: Basically u must put 10min and 5 min together to save time. also, during return path-u must have some1 with less time already there. that's it ! On Tue, Jul 5, 2011 at 1:00 PM, udit sharma sharmaudit...@gmail.com wrote: Q-8: 50,25,10,10,10,10 Q2-: Let A,B,C and D are the persons

[algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread ankit mehta
I think that for Q3 answer will be unique and will be same as pointed out by Ritesh. On Jul 5, 1:11 pm, vikas mehta...@gmail.com wrote: Sum of all the digits should be 8 But it was not said by the interviewer i think we must print all possible combinations for the question -- You received

[algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread Dumanshu
ans1. use counting sort for character array (0 to 255) then check for the second string if same or not. ans2. send 1 and 2, 1 comes back, send 10 and 5, 2 comes back, send 2 and 1 ans3. As vikas said, sum of digits should b 8. In that case the number must have a zero digit because 1st digit the

[algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread Dumanshu
@Azhar: could u plz explain the q8. problem. On Jul 5, 12:13 pm, Azhar Hussain azhar...@gmail.com wrote: Q8 is a DP problem, here is the solution #include stdio.h #define MAX 125 #define VAL 6 int Min[MAX]; int N[VAL] = {5, 10, 20, 25, 50, 100}; int main(void) {     int i, j;    

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread saurabh singh
well for question 6 I think calculating size of string will count as one traversal? Correct me if I am wrong? My approach: traverse storing each char in a string.when space encountered push the string in stack I am not sure how my solution is but it doesnt appears gud ryt now. On Tue, Jul 5,

[algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread Dumanshu
@Saurabh: u can improve upon ur solution. char * outstr; int c =0; void getreversedwords(string str) { index = str.length()-1; //outstr is the answer stack st; while(index) { st.push(str[index]); if(st.top() == ' ') //top is a space st.printstack(); index--; } if(st.isEmpty()==false)

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread saurabh singh
I mean is the solution valid? Because pushing will take one traversal and then popping another? On Tue, Jul 5, 2011 at 4:58 PM, Dumanshu duman...@gmail.com wrote: @Saurabh: u can improve upon ur solution. char * outstr; int c =0; void getreversedwords(string str) { index = str.length()-1;

[algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread anonymous procrastination
The answer to question 3 can also be 6010 right? so no unique solution? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread uttam tiwari
@anonymous: nopes , it's wrong1 is one time there so that should be their at index 1.. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread Azhar Hussain
For Q4: I think this is the optimal code int recurPalin(char *start, char *end) { if (end start) return true; if (*start != *end) return false; return recurPalin(start+1, end-1); } - Azhar. On Tue, Jul 5, 2011 at 12:21 PM, vikas mehta...@gmail.com wrote: My

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread aditya kumar
boolean palindromeCheck(String string) { len=string.length(); if((string.length()1)) { if((string.charAt(0)==string.charAt(len-1))) { str=; str=str+string.substring(1,(len-1)); palindromeCheck(str); } else { flag=false; } } return flag; } THis also works fine if you dont want to use pointer

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread aditya kumar
Q3. ans:7000 i guess this is also a correct answer and no unique soln as such On Wed, Jul 6, 2011 at 12:37 AM, aditya kumar aditya.kumar130...@gmail.comwrote: boolean palindromeCheck(String string) { len=string.length(); if((string.length()1)) {

[algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread L
@aditya : I am wondering how many times 7 has occurred. Is it 1? Or is it 0? Please take a moment before posting your solution, and think whether it is write or wrong! On Jul 6, 12:11 am, aditya kumar aditya.kumar130...@gmail.com wrote: Q3. ans:7000 i guess this is also a correct answer and

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread aditya kumar
in 7000 : '0' occurs seven times and rst of the numbers occur zero times. i still dint get where i am wrong . plz explain me . On Wed, Jul 6, 2011 at 12:47 AM, L prnk.bhatna...@gmail.com wrote: @aditya : I am wondering how many times 7 has occurred. Is it 1? Or is it 0? Please take a

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread Piyush Kapoor
7 occurs 1 time... so 8th digit is 1 On Wed, Jul 6, 2011 at 1:02 AM, aditya kumar aditya.kumar130...@gmail.comwrote: in 7000 : '0' occurs seven times and rst of the numbers occur zero times. i still dint get where i am wrong . plz explain me . On Wed, Jul 6, 2011 at 12:47 AM, L

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread Nitish Garg
But '7' has also appeared One time, you need to take that into account. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To view this discussion on the web visit https://groups.google.com/d/msg/algogeeks/-/djbLMkBkRiUJ. To post to this group,

Re: [algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread aditya kumar
@piyush : thanks i thot most significant bit was take as fisrt figure . On Wed, Jul 6, 2011 at 1:03 AM, Piyush Kapoor pkjee2...@gmail.com wrote: 7 occurs 1 time... so 8th digit is 1 On Wed, Jul 6, 2011 at 1:02 AM, aditya kumar aditya.kumar130...@gmail.com wrote: in 7000 : '0' occurs

[algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread ankit arun
no 7000 is not possible because, '7' is also there so you have to mention at the index of '7' that it is there 1 time.. On Jul 6, 12:32 am, aditya kumar aditya.kumar130...@gmail.com wrote: in 7000 : '0' occurs seven times and rst of the numbers occur zero times. i still dint get where i

[algogeeks] Re: Some adobe interview questions.

2011-07-05 Thread shiv narayan
@ashish thanx buddy nice solution On Jul 6, 7:20 am, Ashish Goel ashg...@gmail.com wrote: Q3 : 42101000 started with 7000 then changes this to 6010 51000100 to 42101000 to Best Regards Ashish Goel Think positive and find fuel in failure +919985813081 +919966006652 On