Re: [algogeeks] Re: Maximum size square sub-matrix with all 1s

2012-01-10 Thread Yogesh Yadav
g[][]- given matrix r[][]- result matrix copy first row n column from g[][] to r[][] rest for i=1 to n-1 for =1 to n-1j if(g[][]) r[][]=min(r[i][j-1],r[i-1][j],r[i-1][j-1])+1; else r[][]=0; On Wed, Jan 11, 2012 at 10:00 AM, Gene gene.ress...@gmail.com wrote: The 1's and 0's

Re: [algogeeks] urgent soln needed

2011-09-30 Thread Yogesh Yadav
Already discussed https://groups.google.com/group/algogeeks/browse_thread/thread/8a3e1a6665702f54/66bb2e804b43ae1d?hl=enlnk=gstq=MS+question+ankur#66bb2e804b43ae1d . On Fri, Sep 30, 2011 at 2:59 PM, sumit kumar pathak sumitkp1...@gmail.comwrote: *find all the zeros in first iteration and

Re: [algogeeks] yahoo qn

2011-09-28 Thread Yogesh Yadav
Count number of space... Add 1 in it... that will be the no of words (say x)... now take two variables m n m=x/2 n =2 //if m is odd =3 //if m is even now store the values in array a[] as a[0]=m a[1]=(m+n)mod(x) a[2]=(m+n)mod(x) . .

Re: [algogeeks] Re: MS question

2011-09-27 Thread Yogesh Yadav
Suppose matrix is 1 0 0 1 1 0 1 0 0 0 0 0 then we traverse the matrix for each 1 we found at a[i][j] , we will check for i=i to irow and j=j to jcol if that contains any more 1 if it contains 1 in row then we don't make the whole row as 1..we ignore the row and same will be for column

Re: [algogeeks] Frequency of number

2011-09-27 Thread Yogesh Yadav
Take an array a[1000]input first 1000 values from the stream in it.. Here we are representing a unit time with help of space because 1000 elements in a stream will always come in constant time So just count the occurrence of a given number in that array... then divide the count with 1000

Re: [algogeeks] Re : Non Decreasing Numbers

2011-09-25 Thread Yogesh Yadav
n=1 n=2 n=3 n=4 01010!(10!)! 1 9 9! (9!)! 2 8 8! 3 7 7! 4 6 6! 5 5 5! 6 4

Re: [algogeeks] Re : Non Decreasing Numbers

2011-09-25 Thread Yogesh Yadav
mistake in last post...it was not factorialsum upto n i.e =n(n+1)/2 i.e 10! is wrong ...it will be 10(10+1)/2 On Sun, Sep 25, 2011 at 12:14 PM, Yogesh Yadav medu...@gmail.com wrote: n=1 n=2 n=3 n=4 01010!(10!)! 1

Re: [algogeeks] Re : Non Decreasing Numbers

2011-09-25 Thread Yogesh Yadav
+1 Gohana On Sun, Sep 25, 2011 at 12:28 PM, Sanjay Rajpal srn...@gmail.com wrote: let the number of digits be n then answer would be ((n+9)! ) / (9! * n!) Sanju :) On Sat, Sep 24, 2011 at 11:51 PM, Yogesh Yadav medu...@gmail.com wrote: mistake in last post...it was not factorial

Re: [algogeeks] Re: Amazon OS question

2011-09-25 Thread Yogesh Yadav
T1-T2-T3-T6 T1-T2-T4-T7 T1-T2-T5-T8 2 Processor: (T1-T2) ..2 TS (T3T4)...1 TS (T6T5)...1 TS (T7T8)...1 TS 4 Processor (T1-T2) ..2 TS (T3T4T5)...1 TS (T6T7T8)...1 TS . On Sun, Sep 25, 2011 at 2:33 PM, siva viknesh sivavikne...@gmail.comwrote: plz give detailed

Re: [algogeeks] Amazon Interview Question

2011-09-24 Thread Yogesh Yadav
we cant traverse the string twice... if there is an error in my logic then plz tell my logic is: we have to take starting and ending indexes for '0','1','2' like below 0 1 2 starting_index ending_index now suppose our string 102112011 so we

Re: [algogeeks] plz reply quickly

2011-09-23 Thread Yogesh Yadav
I am not sure about these...but i guess this will do the job In Linked List: (rear-next==front) In Array: after reaching the maximum size or the end of queue ...just add one more element in queue... and after addition just check (queue[front]==new_element_added) ... if yes then circular queue

Re: [algogeeks] Re: question

2011-09-22 Thread Yogesh Yadav
@algo geek: there is some error in your logic... consider a number 759845 according to ur logic the number greater than this will be 784559 but it should be 759854 . On Thu, Sep 22, 2011 at 4:24 PM, algo geek geeka...@gmail.com wrote: Keep a pointer ont the rightmost digit. Keep

Re: [algogeeks] Re: question

2011-09-22 Thread Yogesh Yadav
digit =4 search for smaller digit than 4 towards left... it will be 3... then answer 759453 On Thu, Sep 22, 2011 at 4:40 PM, Yogesh Yadav medu...@gmail.com wrote: @algo geek: there is some error in your logic... consider a number 759845 according to ur logic the number greater than

Re: [algogeeks] Re: tree to list

2011-09-22 Thread Yogesh Yadav
inorder traversal will do the job... just make sure to create links... On Thu, Sep 22, 2011 at 1:48 AM, Gene gene.ress...@gmail.com wrote: #include stdio.h typedef struct node_s { int data; struct node_s *left, *right; } NODE; // Convert BST to a sorted list connected by -right

Re: [algogeeks] Re: question

2011-09-22 Thread Yogesh Yadav
759435 now am i right?? On Thu, Sep 22, 2011 at 4:55 PM, Ratan success.rata...@gmail.com wrote: the answer should be 759435... On Thu, Sep 22, 2011 at 4:45 PM, Yogesh Yadav medu...@gmail.com wrote: my logic: if wrong then plz tell... start from rightmost digit and search towards

Re: [algogeeks]

2011-09-22 Thread Yogesh Yadav
Ans. 512 ... On Thu, Sep 22, 2011 at 5:38 PM, Rohit Upadhyaya mailtoroh...@gmail.comwrote: int main() { int a=256; char *p=a; *++p=2; printf(%d,a); return(0); } -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

Re: [algogeeks] Question --

2011-09-20 Thread Yogesh Yadav
+1 abhinav but u forgot to change array again into bits... ... On Tue, Sep 20, 2011 at 1:02 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: What are u doing in the first loop running for k=31 to k =0? On Tue, Sep 20, 2011 at 12:50 PM, abhinav gupta guptaabhinav...@gmail.com

Re: [algogeeks] Re: Question --

2011-09-20 Thread Yogesh Yadav
@ishan: there is error in your loop bro... for(k=31;k=0;k++) it should be k-- . On Tue, Sep 20, 2011 at 3:10 PM, vijay singh vijaysinghb...@gmail.comwrote: On Tue, Sep 20, 2011 at 2:16 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: Hi, When I am running this program, I am

Re: [algogeeks] Amazon question SDE

2011-09-20 Thread Yogesh Yadav
@saurabh: i think may be u left some part of question to mention... the array may be a heap array ... or if the ques is correct then i don't think this sum can be possible in O(log n) for previously existing array... may be we have to make array from start...then as you mention we can use

Re: [algogeeks] All valid dictionary words must be found and printed.

2011-09-19 Thread Yogesh Yadav
i=0; char *str; while(a[i]!=NULL) { j=0; while(j!=i) { for(k=j;k=i;k++) { l=0; str[l]=a[j]; } if(Dictionary.findword(str)) printf(str); j++; } } ... On Mon, Sep 19, 2011 at 8:20 PM, Sangeeta sangeeta15...@gmail.com wrote: given

Re: [algogeeks] All valid dictionary words must be found and printed.

2011-09-19 Thread Yogesh Yadav
, Yogesh Yadav medu...@gmail.com wrote: i=0; char *str; while(a[i]!=NULL) { j=0; while(j!=i) { for(k=j;k=i;k++) { l=0; str[l]=a[j]; } if(Dictionary.findword(str)) printf(str); j++; } } ... On Mon, Sep 19, 2011 at 8

Re: [algogeeks] K-LCS

2011-09-18 Thread Yogesh Yadav
struct string_node { char str[]; int length; struct string_node *ptr; } now traverse the strings and saving strings in str[],their length in length and point it to next string_node On Sun, Sep 18, 2011 at 4:47 PM, pooja pooja27tan...@gmail.com wrote: Can some one please help me

Re: [algogeeks] Re: K-LCS

2011-09-18 Thread Yogesh Yadav
... ... On Sun, Sep 18, 2011 at 5:24 PM, pooja pooja27tan...@gmail.com wrote: sorry.. i meant the longest common substring.. eg. consider 4 string.. ababa , bab , babba, abab so the longest common substring is bab. On Sep 18, 4:40 pm, Yogesh Yadav medu...@gmail.com wrote: struct string_node

Re: [algogeeks]

2011-09-18 Thread Yogesh Yadav
current position is index n (say) largest=0; second_largest=0; for(i=1;i=n;i++) { if(a[i]a[n]) { if(a[i]largest) { second_largest=largest; largest=a[i]; } elseif(a[i]second_largest) second_largest=a[i]; } } On Mon, Sep 19, 2011 at 2:15 AM, sagar pareek sagarpar...@gmail.com wrote: Give

Re: [algogeeks] Plz explain the output..........

2011-09-17 Thread Yogesh Yadav
x==9 is not an error... it will be 1 when true and 0 when false...and both are executable statements... when we print float with %d then compiler prints 0...and when we print integer with %f then compiler prints last assigned or printed float value to any float variablehere it is assigned

Re: [algogeeks] Plz explain the output..........

2011-09-17 Thread Yogesh Yadav
@Ashima.. u r right...it is always printing first float variable value On Sat, Sep 17, 2011 at 2:05 PM, Ashima . ashima.b...@gmail.com wrote: @yogesh : but if in place of x=1 in above code, I write t=54. that means i m assigning somevalue to a float variable.Then it should print 54

Re: [algogeeks] C Problem

2011-09-17 Thread Yogesh Yadav
4,5 statements inside sizeof() does not get executed...it will tell just size... int a=3; printf(%d,sizeof(a++)); here a++ will not be executed ...it will just tell size ... Also, lets suppose it execute statements ...then sizeof(int),sizeof(node *) ...will always produce error because int

Re: [algogeeks] Directi Questions - needed answers

2011-09-17 Thread Yogesh Yadav
Ans 1. apply bubble sort. outer loop should run just two times because in 2nd time the 2nd largest element will be at 2nd last position... comparisons=(n-1)+(n-2) On Sat, Sep 17, 2011 at 4:27 PM, Ashima . ashima.b...@gmail.com wrote: ans 2: http://www.qbyte.org/puzzles/p131s.html Ashima

Re: [algogeeks] Directi Questions - needed answers

2011-09-17 Thread Yogesh Yadav
)Information Systems 4th year BITS Pilani Rajasthan On Sat, Sep 17, 2011 at 4:20 AM, Yogesh Yadav medu...@gmail.com wrote: Ans 1. apply bubble sort. outer loop should run just two times because in 2nd time the 2nd largest element will be at 2nd last position... comparisons=(n-1)+(n-2) On Sat

Re: [algogeeks] Directi Questions - needed answers

2011-09-17 Thread Yogesh Yadav
, Yogesh Yadav medu...@gmail.com wrote: Ans 1. apply bubble sort. outer loop should run just two times because in 2nd time the 2nd largest element will be at 2nd last position... comparisons=(n-1)+(n-2) On Sat, Sep 17, 2011 at 4:27 PM, Ashima . ashima.b...@gmail.com wrote: ans 2: http

Re: [algogeeks] Directi Questions - needed answers

2011-09-17 Thread Yogesh Yadav
the basic operation is comparision so we can express comaprision in terms of order of O(n). newazz we still require n-1 comparisions to find second max . On Sat, Sep 17, 2011 at 5:06 PM, Yogesh Yadav medu...@gmail.com wrote: @aditya: comparing isn't complexity here... here it means

Re: [algogeeks] Directi Questions - needed answers

2011-09-17 Thread Yogesh Yadav
12 west ...12 south On Sat, Sep 17, 2011 at 5:24 PM, Dheeraj Sharma dheerajsharma1...@gmail.com wrote: 12 west and 10 south.. i thnk..is the correct one.. On Sat, Sep 17, 2011 at 5:22 PM, Yogesh Yadav medu...@gmail.com wrote: yeah it will be 62.5% On Sat, Sep 17, 2011 at 5:14 PM

Re: [algogeeks] Re: Directi Questions - needed answers

2011-09-17 Thread Yogesh Yadav
Q3. 101 matches .. On Sun, Sep 18, 2011 at 8:02 AM, VIHARRI viharri@gmail.com wrote: hey i'm also thinking n + logn -2.. but couldnt able to figure out how??? can you please explain the logic -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] Find the output

2011-09-16 Thread Yogesh Yadav
a[]= {1, 2, 3, 4,5} a a a+1 a+1 a is address of whole array...so a+1 means next element after array completion. so ptr-1 will point to 5 ... On Fri, Sep 16, 2011 at 1:25 PM, Anup

Re: [algogeeks] Re: Microsoft Question

2011-09-15 Thread Yogesh Yadav
For Stack: just make a structure: struct stack_with_priorityqueue { int num; int priority; struct stack_with_priorityqueue *ptr; } now when we add another number just increase the priority... priority++ For Queue: do same...just decrease priority...priority-- ...

Re: [algogeeks] Find the element in Array

2011-09-15 Thread Yogesh Yadav
*//this method can be applied only when the value of elements in array are not very large int count[]; for(i = 0 to n-1) { if(count[arr[i]] == 1) printf( %d , arr[i]); else count[arr[i]]++; }* .. On Wed, Aug 31, 2011 at 12:38 PM, Yuchen Liao lycdra...@gmail.com wrote:

Re: [algogeeks] pgm3

2011-09-13 Thread Yogesh Yadav
//don't know this is completely correct or not 1.find sum of elements of both arrays a[] and b[]...from 0 to n-1 2.check whichever is smaller sum_a or sum_b...say sum_a is smaller 3.generate a random number i=random(sum_a)... generates random number between o to (sum_a)-1 //random

Re: [algogeeks]

2011-09-07 Thread Yogesh Yadav
prime no has only 2 factors. number itself and 1. On Wed, Sep 7, 2011 at 12:14 PM, aayush jain ajain...@gmail.com wrote: can anybody tell me the code of find the prime no. and after finding prime no. find its prime factore using linkes list?? -- You received this message because you

Re: [algogeeks] MS question

2011-09-05 Thread Yogesh Yadav
//Num is our given number obtained from date Int num1,num2; Int count1=0,count2=0; void nearestpalindrome() { Num1=num; For(;;) { If(Checkpalindrome(num1))

Re: [algogeeks] MS question

2011-09-05 Thread Yogesh Yadav
//Num is our given number obtained from date 1.divide num into 2 parts last 4 and first 4 ex: num=96548765 num1=9765,num2=Reverse(8765) 2.if(num1num2) add(num1-num2) in num2 3. num3=reverse(num2) palindrome=num1||num3 On Mon, Sep 5, 2011 at 10:51 PM, Neha Singh

Re: [algogeeks] MS question

2011-09-05 Thread Yogesh Yadav
@all : Thanks for correcting me. On Tue, Sep 6, 2011 at 3:41 AM, Piyush Grover piyush4u.iit...@gmail.comwrote: Here's the pseudo code. I hope it should work. d = date-string (d[0]d[1]) m = month-string (m[0]m[1]) y = year-string (y[0]y[1]y[2]y[3]) dd = d; mm = m; yy = y; while(1){

Re: [algogeeks] c problem

2011-09-04 Thread Yogesh Yadav
@Priya: Lvalue is not a contant value. It can be modifiable or unmodifiable. Lvalue stands for location value that means that we can store some value here in this location and rvalue stands for read value that means that it can be stored at some location that is in memory having lvalue. Here in

Re: [algogeeks] c problem

2011-09-04 Thread Yogesh Yadav
@Priya: Because a is *unmodifiable* LValue. When we are using a=a+1(a++) , this means that we are changing the *base address* of array a[], and that can not be possible due to Library files. On Sun, Sep 4, 2011 at 11:49 AM, priya ramesh love.for.programm...@gmail.com wrote: @yogesh: Thanks a

Re: [algogeeks] Re: Algorithms For Interviews

2011-08-16 Thread Yogesh Yadav
plz upload it againi cant open it... On Tue, Aug 16, 2011 at 8:31 PM, Nitin Nizhawan nitin.nizha...@gmail.comwrote: sent to you ravi On Tue, Aug 16, 2011 at 8:16 PM, ravi kumar ravikumar...@gmail.comwrote: heyy nitin.. it says da file izz locked .. can u mail me da buk.. thanx in

Re: [algogeeks] Re: amazon

2011-07-19 Thread Yogesh Yadav
Part 1: Take 2 pointers moving at different speed... 1st with head-next 2nd with head-next-next when 2nd will reach the end 1st will be pointing middle... so one result is obtained Part 2: when 1st result is obtained then start with the node pointed by 1st as it will be on 1/2th part of the

Re: [algogeeks] Re: amazon

2011-07-19 Thread Yogesh Yadav
to 3/4th, same way for m/n th node. But this works best for even number of nodes in list. For odd numbers we need to compromise like finding the middle node :) Cheers, Mani On Tue, Jul 19, 2011 at 4:20 PM, Yogesh Yadav medu...@gmail.com wrote: Part 1: Take 2 pointers moving at different

Re: [algogeeks] Re: GOOGLE Q1

2011-07-11 Thread Yogesh Yadav
with matrix this problem will be in O(n^2). We don' have to just check the max number present in matrix. We have to check as array a[]= 1,2,3,4,5,6,8,10,12,14 diff[][]= 1 2 3 4 5 6 8 10 12 14 2 0 1 2 3 4 6 8 10 12 3 -1 0 1 2 3 5 79 11

Re: [algogeeks] MS

2011-07-11 Thread Yogesh Yadav
largest size of square would be = H.C.F of width and height . now with size known we have to just arrange squares this can be done such that we can make a big square by adding them... for ex 1st square can be made by just (1 square) 2nd square can be made by adding 3 sqaures around it

Re: [algogeeks] MS

2011-07-11 Thread Yogesh Yadav
largest size of square would be = H.C.F of width and height . now with size known we have to just arrange squares this can be done such that we can make a big square by adding them... for ex 1st square can be made by just (1 square) 2nd square can be made by adding 3 sqaures around it

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
array a[] stores numbers for(i=1;in;i++) { diff[i-1]=a[i]-a[i-1]; } maxcount=1; tempcount=1; for(j=1;jn-1;j++) { if(diff[j]==diff[j-1]) tempcount++; else { if(tempcountmaxcount) maxcount=tempcount; tempcount=1; } } On Sat, Jul 9, 2011

Re: [algogeeks] macro

2011-07-10 Thread Yogesh Yadav
Thats wonderful para :) On Sat, Jul 9, 2011 at 10:50 AM, John Hayes agressiveha...@gmail.comwrote: refer KRit's clearly mentioned in it On Sun, Jul 10, 2011 at 12:12 AM, parag khanna khanna.para...@gmail.comwrote: no text substitution occurs if the identifier is within the quotes

Re: [algogeeks] macro

2011-07-10 Thread Yogesh Yadav
Thats wonderful parag :) On Sun, Jul 10, 2011 at 4:56 AM, Yogesh Yadav medu...@gmail.com wrote: Thats wonderful para :) On Sat, Jul 9, 2011 at 10:50 AM, John Hayes agressiveha...@gmail.comwrote: refer KRit's clearly mentioned in it On Sun, Jul 10, 2011 at 12:12 AM, parag khanna

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
@raj : array a[]= 2,3,5,6,7,8,10,12 diff[]= 1,2,1,1,1,2,2 maxcount=tempcount=1 // because am not takin in consideration of 0th index value of diff[] now in for loop for j=1 check diff[j]==diff[j-1] //not equal so check tempcountmaxcount or not //its also not so maxcount remains same

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
i thinks mine is just O(n) On Sun, Jul 10, 2011 at 5:31 AM, Yogesh Yadav medu...@gmail.com wrote: @raj : array a[]= 2,3,5,6,7,8,10,12 diff[]= 1,2,1,1,1,2,2 maxcount=tempcount=1 // because am not takin in consideration of 0th index value of diff[] now in for loop for j=1 check

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
A[] = {1,2,3,4,5,6,8,10,12,14} your algo will give output that there is an Longest AP of 6 elements which is wrong checkout this http://theory.cs.uiuc.edu/%7Ejeffe/pubs/pdf/arith.pdf for an O(n^2) algorithm On Sun, Jul 10, 2011 at 7:01 PM, Yogesh Yadav medu...@gmail.com wrote: @raj : array

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
A[] = {1,2,3,4,5,6,8,10,12,14} your algo will give output that there is an Longest AP of 6 elements which is wrong checkout this http://theory.cs.uiuc.edu/%7Ejeffe/pubs/pdf/arith.pdf for an O(n^2) algorithm On Sun, Jul 10, 2011 at 7:01 PM, Yogesh Yadav medu...@gmail.com wrote: @raj : array

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
A[] = {1,2,3,4,5,6,8,10,12,14} your algo will give output that there is an Longest AP of 6 elements which is wrong checkout this http://theory.cs.uiuc.edu/%7Ejeffe/pubs/pdf/arith.pdf for an O(n^2) algorithm On Sun, Jul 10, 2011 at 7:01 PM, Yogesh Yadav medu...@gmail.com wrote: @raj : array

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
work On Sun, Jul 10, 2011 at 7:18 PM, Yogesh Yadav medu...@gmail.com wrote: @sunny: my algo will give 6 as answer and i guess its right... if am wrong plz explain where and why my logic is wrong On Sun, Jul 10, 2011 at 5:37 AM, sunny agrawal sunny816.i...@gmail.comwrote: @Yogesh your

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
yeah then it will be possible in O(n^2) On Sun, Jul 10, 2011 at 5:57 AM, Yogesh Yadav medu...@gmail.com wrote: @sunny : thanks ..i got it... On Sun, Jul 10, 2011 at 5:55 AM, sunny agrawal sunny816.i...@gmail.comwrote: Longest AP for that Example is of 7 elements 2,4,6,8,10,12,14

Re: [algogeeks] GOOGLE Q1

2011-07-10 Thread Yogesh Yadav
Step 1: first make a diff[][] Step 2: search the diff in matrix Complexity will be O(n^2) On Sun, Jul 10, 2011 at 6:24 AM, JAIDEV YADAV jaid...@gmail.com wrote: try Matrix search... On Sun, Jul 10, 2011 at 7:34 PM, Yogesh Yadav medu...@gmail.com wrote: yeah then it will be possible in O

Re: [algogeeks] puzzle

2011-07-09 Thread Yogesh Yadav
91,110,134161 i guess 6,24,60,120210 On Sat, Jul 9, 2011 at 5:46 PM, Aman Goyal aman.goya...@gmail.com wrote: 210 for the last one you posted On Sat, Jul 9, 2011 at 4:33 PM, amit the cool amitthecoo...@gmail.comwrote: 6,24,60,120,_ -- You received this message because you are

Re: [algogeeks] BIT MANIPULATION

2011-07-09 Thread Yogesh Yadav
int count1=count2=0; given number=n; int m=n; //save in temp variable m while(m!=0) //count number of bits in given number { m=m (m-1); count1++; } m=n; //save in temp variable m while(count1!=count2) //check no. of bits same or not { m=m+1;

Re: [algogeeks] Re: Interview question

2011-07-09 Thread Yogesh Yadav
@gopi: i didnt really understand what u want to say... what start,end and destination denotes here?? u said it should start with 1 but in result it is starting with 9...plz explain ur question again On Sat, Jul 9, 2011 at 7:21 PM, Gopi kodaligopi...@gmail.com wrote: Hi Geeks Can anyone

Re: [algogeeks] Re: Merging Sorted Arrays

2011-07-08 Thread Yogesh Yadav
size of a=m size of b =n a[]={1,3,77,78,90} and b[]={2,5,79,81} lr while(l=m r=n) { if(b[r]a[l]) { swap(a[l],b[r]); l++; sort(b[]); } elseif(a[l]b[r]) l++; } On Fri, Jul 8,

Re: [algogeeks] Re: find the integer

2011-07-08 Thread Yogesh Yadav
a[]={2,2,3,3,3,4,4,5,6,6,7} size of array = n if not sorted than sort for(i=1;in-1;i++) //check for elements with index 1 to n-2 { if(a[i]!=a[i-1] a[i]!=a[i+1]) print(a[i]); } //now check for index 0 and n-1 if(a[0]!=a[1]) print(a[0]); if(a[n-1]!=a[n-2])

Re: [algogeeks] GOOGLE Q3

2011-07-08 Thread Yogesh Yadav
let 10 digit phone number stored in array a[] take a array b[10] and initialise its elements with 0 int gp2[][2]; // group with 2 elements will store here int gp3[][3]; // group with 3 elements will store here int l=0,r=0,count=0; int m[],n; //l,m,n is global for(i=0;i10;i++)

Re: [algogeeks] GOOGLE Q3

2011-07-08 Thread Yogesh Yadav
++; n--; } On Sat, Jul 9, 2011 at 2:27 AM, Yogesh Yadav medu...@gmail.com wrote: let 10 digit phone number stored in array a[] take a array b[10] and initialise its elements with 0 int gp2[][2]; // group with 2 elements will store here int gp3[][3]; // group with 3 elements

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 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