Re: [algogeeks] Find longest consecutive subsequence

2014-01-27 Thread Nishant Pandey
); vc.push_back(2); cout endl longest_sequence(vc); return 0; } NIshant Pandey Cell : 9911258345 Voice Mail : +91 124 451 2130 On Mon, Jan 27, 2014 at 4:29 PM, Amol Sharma amolsharm...@gmail.com wrote: Given an array of positive numbers arranged in any order. You have to find the length of longest

Re: [algogeeks] DISTINCT Permutations ( Not Easy)

2014-01-07 Thread Nishant Pandey
); Permute(str,start+1,end); swap(str,start,i); } } } int main() { char Str[]=aba; Permute(Str,0,strlen(Str)-1); return 0; } NIshant Pandey Cell : 9911258345 Voice Mail : +91 124 451 2130 On Tue, Jan 7, 2014 at 4:44 PM, kumar raja rajkumar.cs...@gmail.com wrote: This u

Re: [algogeeks] How to read multiple utf-8 encoded string from stdin

2013-11-26 Thread Nishant Pandey
...@gmail.comwrote: From StackOverflow, --- fgets() can decode UTF-8 encoded files if you use Visual Studio 2005 and up. Change your code like this: infile = fopen(inname, r, ccs=UTF-8); On Sat, Nov 23, 2013 at 8:25 PM, Nishant Pandey nishant.bits.me...@gmail.com wrote

Re: [algogeeks] How to read multiple utf-8 encoded string from stdin

2013-11-26 Thread Nishant Pandey
+ 2]; /* 2 Extra for \0 \n */ memset(buff,0,sizeof(buff)); /* fgets reads max one less than provided length so adding 1 */ while (NULL != fgets(buff,MAX_BUFF+1,fd)) printf(%d\n, non_ascii_count(buff)); return 0; } On Tue, Nov 26, 2013 at 7:43 PM, Nishant Pandey nishant.bits.me

Re: [algogeeks] How to read multiple utf-8 encoded string from stdin

2013-11-25 Thread Nishant Pandey
if you use Visual Studio 2005 and up. Change your code like this: infile = fopen(inname, r, ccs=UTF-8); On Sat, Nov 23, 2013 at 8:25 PM, Nishant Pandey nishant.bits.me...@gmail.com wrote: Q) *C program* that reads multiple UTF-8 encoded strings from STDIN (1 string per line), count all *non

[algogeeks] How to read multiple utf-8 encoded string from stdin

2013-11-23 Thread Nishant Pandey
Q) *C program* that reads multiple UTF-8 encoded strings from STDIN (1 string per line), count all *non-ascii* characters (ascii characters are with ordinal decimal 0 to 127) and print the total non-ascii character count to STDOUT (1 number per line). Contraint : - You cannot use any

Re: [algogeeks] Re: Intrestting problem

2013-06-12 Thread Nishant Pandey
juat want to ask why the last region was not flipped from o to x? On Tue, Jun 11, 2013 at 11:57 PM, Don dondod...@gmail.com wrote: // Flip a region including location (x,y) from from to to. // Returns true if region is surrounded. bool flip(char board[][], int n, int x, int y, char from,

[algogeeks] circumference of a tree going clockwise and anticlockwise?

2013-06-01 Thread Nishant Pandey
does that means displaying only boundary elements of tree and if yes in which order ? *My Answer* : I think it would be something like doing preorder travesal of left subree with boundary elements and leaf elements of left subtree + post order traversal of right subtree with boundary element and

Re: [algogeeks] How will you implement a stack using a priority queue. Push and pop should be in O(1)

2013-05-26 Thread Nishant Pandey
17:52, rohit jangid rohit.nsi...@gmail.com wrote: you are doing it correct. On Sat, May 25, 2013 at 5:37 PM, Nishant Pandey nishant.bits.me...@gmail.com wrote: I am not getting the y priority Q is getting used for this question, as in case of P Queue, things are arranged as per

Re: [algogeeks] What data structures will you use to implement a text editor. Size of editor can be changed and you also need to save the styling information for all the text like italic, bold etc.EO

2013-05-26 Thread Nishant Pandey
. On Sun, May 26, 2013 at 9:36 AM, Ravi Ranjan ravi.cool2...@gmail.comwrote: Rope On Sat, May 25, 2013 at 10:24 PM, Nishant Pandey nishant.bits.me...@gmail.com wrote: In one of the interview it was asked, can some one suggest good DS for this. Thanks -- You received this message

Re: [algogeeks] inplace merge of 2 sorted parts of an array

2013-05-26 Thread Nishant Pandey
The solution could be given in this way. 1) In one pass get the end index of both array says e1 and e2. 2) now in next pass compare elements at e1 and e2 . a) if a(e1) a(e2) swap the elements and then decreament e1 and e2 both. b) if a(e1) a(e2) decreament e2. c) if a(e1) == a(e2) then

Re: [algogeeks] Re: count number of set bits in an (big) array (Asked in Google interview)

2013-05-26 Thread Nishant Pandey
@DOn can u explain ur first algo, it would be helpful. On Wed, May 22, 2013 at 7:28 PM, Don dondod...@gmail.com wrote: My program works with any numbers. Don On May 22, 3:45 am, Pramida Tumma pramida.tu...@gmail.com wrote: This above program works only if the array contains consecutive

[algogeeks] How will you implement a stack using a priority queue. Push and pop should be in O(1)

2013-05-25 Thread Nishant Pandey
I am not getting the y priority Q is getting used for this question, as in case of P Queue, things are arranged as per the priority so when we will insert the data we can simply increament the priority. Algo would be like this : Enque(q, data) { push(q, data, increrase the prioroty); } int

[algogeeks] What data structures will you use to implement a text editor. Size of editor can be changed and you also need to save the styling information for all the text like italic, bold etc.EOM

2013-05-25 Thread Nishant Pandey
In one of the interview it was asked, can some one suggest good DS for this. Thanks -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to

[algogeeks] PLease suggest the Algo for this problem

2013-05-23 Thread Nishant Pandey
I have a list of N teams T1, T2, T3 … Tn. Each of these teams has played a match against every other team. I have a function displayResult(Team T1, Team T2), it returns the team which won the match between any two given teams T1 and T2. I have to write the teams in an order such the (n-1)th team

Re: [algogeeks] Re: PLease suggest the Algo for this problem

2013-05-23 Thread Nishant Pandey
the ranking should be A,B,C. But based on the third game, C should be ranked higher than A. Don On May 23, 11:06 am, Nishant Pandey nishant.bits.me...@gmail.com wrote: I have a list of N teams T1, T2, T3 … Tn. Each of these teams has played a match against every other team. I have

[algogeeks] Rope Data Structure Implementation

2013-05-17 Thread Nishant Pandey
I want to implement rope data stucture from scratch in c , is there any good material that can help me implement this with ease. Thanks Nishant -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving

Re: [algogeeks] Re: Print a Random word from a file. Input is path to a file, constraints- No extra memory like hashing etc. All the words in the file should have equal probability.

2013-05-12 Thread Nishant Pandey
On Sunday, May 5, 2013 9:10:37 PM UTC-5, Dave wrote: @Nishant: I'm assuming that you don't know the number of words in the file, and that you don't want to store them all. Here is an algorithm that requires you to store only two words and an integer. Assume double function random() returns

Re: [algogeeks] Array of intergers with repeating elements

2013-05-12 Thread Nishant Pandey
i think u should utilize the property of XOR, this would help. On Wed, May 8, 2013 at 12:02 AM, MAC macatad...@gmail.com wrote: I was asked this in recent amazon onsite interview and asked o write code Given an Array of integers . N elements occur k times and one element occurs b times, in

[algogeeks] I am new to CPP STL please help

2013-05-12 Thread Nishant Pandey
This is my code snippet #include iostream.h #include string #include set #include map #include vector #include sstream #include cctype using namespace std; void work() { mapstring, int name_age; mapint,string index_name; mapint,string index_name_temp; std::map int, string ::iterator it;

[algogeeks] Print a Random word from a file. Input is path to a file, constraints- No extra memory like hashing etc. All the words in the file should have equal probability.

2013-05-05 Thread Nishant Pandey
Hi Guys, In this problem i am wondering how it will be done without extra memory space, though we can easily do it with hashing and random funcs(). Is there any solution for this , Please help. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group.

[algogeeks] For a given set of points find a point along with 3 others that are closest to each other

2013-05-03 Thread Nishant Pandey
Guys i am looking for optimize algorithm for this, please help. -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To unsubscribe from this group and stop receiving emails from it, send an email to algogeeks+unsubscr...@googlegroups.com. For

Re: [algogeeks] Interview Question

2013-04-26 Thread Nishant Pandey
of their set bits and after that in second loop we are xoring only odd ones whose bits are set and we get our ans in variable x and y. Hope u got it . On Fri, Apr 19, 2013 at 11:30 PM, kartik n kartik.car...@gmail.com wrote: Hi Nishant i did not understand the code can u please describe a bit Thanks

Re: [algogeeks] Interview Question

2013-04-19 Thread Nishant Pandey
int main() { int a[] = {1,2,2,3,3,3,4,4}; int size = sizeof(a)/sizeof(a[0]); int xorr=0; for(int i=0;isize;i++) { xorr^=a[i]; } int x=0,y=0; int xor1=xorr ~(xorr-1); for(int i=0;isize;i++) { if(xor1 a[i]) x^=a[i]; else y^=a[i]; } cout xy; } in this 1 and 3 would be output. as it

Re: [algogeeks] Leaf nodes from inorder traversal

2013-03-17 Thread Nishant Pandey
what the issue with this , while doing inorder traversal check if left and right both are null its ur leaf node else keep traversing. If i couldn't understood ur problem , please explain again. On Sat, Mar 16, 2013 at 7:44 PM, Megha Agrawal megha1...@iiitd.ac.inwrote: Hello all, Is it

Re: [algogeeks] Re: Amazon Interview Questions

2013-03-12 Thread Nishant Pandey
-right)) cout root-data; } * *let me knw if anything seems confusing. On Sun, Mar 10, 2013 at 4:59 PM, Nishant Pandey nishant.bits.me...@gmail.com wrote: i have few questions regarding ur problems pratik : 1) A tree with only parent pointer, how to find LCA? Doubt : do u mean only root

Re: [algogeeks] Re: Amazon Interview Questions

2013-03-12 Thread Nishant Pandey
i have few questions regarding ur problems pratik : 1) A tree with only parent pointer, how to find LCA? Doubt : do u mean only root of the tree is given , i am assuming root along with two nodes address whose lca need to find too is given , i am right ? 2) Find top k searched elements

Re: [algogeeks] find out all pairs of numbers a,b such that a^2+b^2 = N

2013-03-12 Thread Nishant Pandey
some thing like would work. int find(int x ) { int p = sqrt(x/2); int total=0; float y; for( int i=0;i=p;i++) { y=sqrt(x*x-i*i); if( y(int) == y) total++; } return total; } find( } On Thu, Feb 14, 2013 at 10:22 AM, Shachindra A C sachindr...@gmail.comwrote: Guneesh, Thanks for the

Re: [algogeeks] Re: FInd unique element.

2013-03-12 Thread Nishant Pandey
i think what aditya suggested is cool but in that instead of going for largest element we need to search smallest value and its index would he number we are looking for. On Sun, Feb 24, 2013 at 7:45 PM, Dave dave_and_da...@juno.com wrote: @Marti: If you know m and k, and if m is even and k is

Re: [algogeeks] Number of paths

2013-02-21 Thread Nishant Pandey
+1 for above approach , its called memotization .. it helps reducing redundant recursive call for the same matter. On Thu, Feb 21, 2013 at 2:29 PM, Karthikeyan V.B kartmu...@gmail.comwrote: Assuming that u can either move down or right, Using Dynamic Programming, a DP equation can be framed

Re: [algogeeks] Amazon interview Question

2013-02-07 Thread Nishant Pandey
what would happen of the input is like this : 5, 5, 66, 66, 7, 1, 1, 77,7 i think in this case the moment window reaches to point (66,7,1) it will take 7 as unique number but that too window will not move any futhur , but 7 is not unique . Please comment if i misunderstood ur explanation .

Re: [algogeeks] size of array

2013-01-30 Thread Nishant Pandey
i already said this is not possible , in my intial draft , as we dont have any information of memory owner in called function , just have base address which is address of single element of the array . On Wed, Jan 30, 2013 at 1:55 PM, Prem Krishna Chettri hprem...@gmail.comwrote: @Piyush ..

Re: [algogeeks] size of array

2013-01-29 Thread Nishant Pandey
i think this is not possible as you are passing only base address of the int array to it , there is not information about the owner . On Mon, Jan 28, 2013 at 3:44 PM, Anil Sharma anilsharmau...@gmail.comwrote: How to calculate the size/lenght of an int array which is passed as an ONLY argument

Re: [algogeeks] Suggested the Data Structure to implement the solution in O(1)

2013-01-08 Thread Nishant Pandey
no i am using C for this implementation , can you suggest me algo for this On Tue, Jan 8, 2013 at 5:55 PM, Sachin Maheshwari sachin.maheshw...@gmail.com wrote: If you are using Java, you can go with LinkedHashMap. On Sat, Jan 5, 2013 at 6:40 PM, Nishant Pandey nishant.bits.me

[algogeeks] Suggested the Data Structure to implement the solution in O(1)

2013-01-07 Thread Nishant Pandey
Give a Data structure to store Name-value pair like name-age abc,12 xyz,34... such than insert(name,value), value = search(name), name = nthentry(n), delete(name); all can be perfomed in O(1). Note:- after deletion order should be maintained.Ex. ds,12 df,78 teu,54 etr,12 If delete(df) is called

Re: [algogeeks] Adobe written test question

2012-10-25 Thread Nishant Pandey
i think arr[10] and int *arr are two different declaration when ,when compiler tried to link with the memory of int arr[10] it could nt find it , as u have declraed it to be integer type pointer , and in file 1 it could find integer pointer . On Wed, Oct 24, 2012 at 11:06 PM, rahul sharma

Re: [algogeeks] Re: [Google] Finds all the elements that appear more than n/3 times

2012-07-11 Thread Nishant Pandey
can some body please explain voting algo to me . On Wed, Jul 11, 2012 at 12:42 PM, Navin Kumar algorithm.i...@gmail.comwrote: @sachin: http://valis.cs.uiuc.edu/~sariel/research/CG/applets/linear_prog/median.html On Wed, Jul 11, 2012 at 12:28 PM, sachin goyal

Re: [algogeeks] Finding intersection of 2 linked lists

2012-07-05 Thread Nishant Pandey
, Abhishek Sharma abhi120...@gmail.comwrote: @nishant, you wrote until both the distance becomes equal.Which distances ? Could you please elaborate ? On Thu, Jul 5, 2012 at 12:52 PM, Ashish Goel ashg...@gmail.com wrote: struct node* intersection( struct node *pL1, struct node* pL2) { if ((!pL1

Re: [algogeeks] Permuatation of string in caase of duplicte string it shouldnt print duplicates permutation .

2012-07-04 Thread Nishant Pandey
function call //swap() flag[str[i]=1; } done On 7/3/12, Nishant Pandey nishant.bits.me...@gmail.com wrote: 1) Find all permutations of a string. 2) Improve it so that the permutations are not repeated, Eg= string is Answer should be just once not 4! times

Re: [algogeeks] Finding intersection of 2 linked lists

2012-07-04 Thread Nishant Pandey
get the size of both the linked list say d1,d2 ; get their diff like df=abs(d1-d2); now take 2 pointers both poiting to the start of both the linked list . go to bigger list now move this pointer until both the distance becomes equal . at this point we have one pointer from smaller list pointing

[algogeeks] Permuatation of string in caase of duplicte string it shouldnt print duplicates permutation .

2012-07-03 Thread Nishant Pandey
1) Find all permutations of a string. 2) Improve it so that the permutations are not repeated, Eg= string is Answer should be just once not 4! times. i want suggestion to improve the recursive code in case of 2) case . -- You received this message because you are subscribed to the

Re: [algogeeks] Inorder Iterative code for printing paths

2012-06-28 Thread Nishant Pandey
printPath(node *p,node *child) { if( p child) std::cout Path: p-data =child-data std::endl; } use this before you assign 'current' to its children. e.g. printPath(p,p-left) or printPath(p,p-right); -- Amitesh On Mon, Jun 25, 2012 at 11:34 PM, Nishant

[algogeeks] Inorder Iterative code for printing paths

2012-06-25 Thread Nishant Pandey
) //coutcurrent-dataendl; current=current-right; if(current) i++; } } } } -- Cheers, Nishant Pandey |Specialist Tools Development | npan...@google.comgvib...@google.com | +91-9911258345 -- You received this message

Re: [algogeeks] Re: Microsoft Interview Question

2012-06-21 Thread Nishant Pandey
://groups.google.com/group/algogeeks?hl=en. -- Cheers, Nishant Pandey |Specialist Tools Development | npan...@google.comgvib...@google.com | +91-9911258345 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email

Re: [algogeeks] Re: Microsoft Interview Question

2012-06-21 Thread Nishant Pandey
to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Cheers, Nishant Pandey |Specialist Tools Development | npan

Re: [algogeeks] Re: Directi question-centre of the tree

2012-06-20 Thread Nishant Pandey
I am asking again .. can any one please suggest better method for getting the median on the longest path of the tree .. efficient method . On Tue, Jun 19, 2012 at 5:08 PM, Nishant Pandey nishant.bits.me...@gmail.com wrote: for getting diameter we can simply add the max height of left subtree

Re: [algogeeks] Re: Directi question-centre of the tree

2012-06-19 Thread Nishant Pandey
...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Cheers, Nishant Pandey |Specialist Tools Development | npan...@google.comgvib...@google.com | +91-9911258345 -- You received this message because you are subscribed to the Google

Re: [algogeeks] Can anyone plz explain how we get this output

2012-06-14 Thread Nishant Pandey
this group at http://groups.google.com/group/algogeeks?hl=en. -- Cheers, Nishant Pandey |Specialist Tools Development | npan...@google.comgvib...@google.com | +91-9911258345 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Nishant Pandey
://groups.google.com/group/algogeeks?hl=en. -- Cheers, Nishant Pandey |Specialist Tools Development | npan...@google.comgvib...@google.com | +91-9911258345 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Nishant Pandey
Algorithm Geeks group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Cheers, Nishant Pandey

Re: [algogeeks] MS Question: Reverse stack using push, pop without any auxiliary data structure

2012-06-14 Thread Nishant Pandey
/algogeeks?hl=en. -- Cheers, Nishant Pandey |Specialist Tools Development | npan...@google.comgvib...@google.com | +91-9911258345 -- 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

Re: [algogeeks] Adobe interiew question

2012-06-13 Thread Nishant Pandey
. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Cheers, Nishant Pandey |Specialist Tools Development | npan...@google.comgvib...@google.com | +91-9911258345 -- You received

Re: [algogeeks] [amazon]: dutch national flag algorithm

2012-06-10 Thread Nishant Pandey
/algogeeks/-/54GHWSwHHw8J. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Cheers, Nishant Pandey

Re: [algogeeks] first Repeating character in a string

2012-06-08 Thread Nishant Pandey
://groups.google.com/group/algogeeks?hl=en. -- Cheers, Nishant Pandey |Specialist Tools Development | npan...@google.comgvib...@google.com | +91-9911258345 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email

Re: [algogeeks] first Repeating character in a string

2012-06-08 Thread Nishant Pandey
to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Cheers, Nishant Pandey |Specialist Tools Development | npan...@google.comgvib...@google.com | +91-9911258345 -- You received this message because you

Re: [algogeeks] Simple Question ,Find Error

2012-06-04 Thread Nishant Pandey
://groups.google.com/group/algogeeks?hl=en. -- Cheers, Nishant Pandey |Specialist Tools Development | npan...@google.comgvib...@google.com | +91-9911258345 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks

Re: [algogeeks] LINKED LIST QUESTION

2012-06-04 Thread Nishant Pandey
email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Cheers, Nishant Pandey |Specialist Tools Development | npan...@google.comgvib...@google.com | +91-9911258345 -- You received this message because you

Re: [algogeeks] Linked list using void pointer

2012-05-31 Thread Nishant Pandey
+ i) = *(char *)(data + i); temp-next = *p; *p = temp; } void(List *p,void (*f)(void*)) { while (p) { (*f)(p-data); p = p-next; } } void printstr(void *str) { printf( \%s\, (char *)str); } Regads Nishant Pandey On Thu, May 31, 2012 at 1:15 PM, Hassan

Re: [algogeeks] MS Question: Delete a node in single linked list if it is less than any of the successor nodes

2012-05-31 Thread Nishant Pandey
...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- Cheers, Nishant Pandey |Specialist Tools Development | npan...@google.comgvib...@google.com | +91-9911258345 -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Linked list using void pointer

2012-05-31 Thread Nishant Pandey
, Nishant Pandey |Specialist Tools Development | npan...@google.comgvib...@google.com | +91-9911258345 -- 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

Re: [algogeeks] Re: C Doubts

2011-07-18 Thread Nishant Mittal
@abhi we can do it without passing the address to a function. just store the address of const variable in another variable and change the value... On Mon, Jul 18, 2011 at 11:56 AM, Abhi abhi123khat...@gmail.com wrote: Perhaps the only way to alter the value of a variable declared constant in C

Re: [algogeeks] Missing Number in an array

2011-07-18 Thread Nishant Mittal
1.Calculate XOR of all the array elements. 2.XOR the result with all numbers from 1 to n =x1 3.After 2nd step, all elements would nullify each other except 2 missing elements(let x and y) and x1 will contain XOR of x and y 4.All the bits that are set in x1 will be set in either x or y. Get the

Re: [algogeeks] Re: Missing Number in an array

2011-07-18 Thread Nishant Mittal
@ankit...i m assuming that array of size n contains n-2 elements with 2 elements missing On Mon, Jul 18, 2011 at 6:07 PM, SAMMM somnath.nit...@gmail.com wrote: #includestdio.h int main() { int a[]={1,2,3,5,2}; // 2 isrepeated and 4 is missing int i=0,x=0,j=0,bit; while(i5) {

Re: [algogeeks] Re: Missing Number in an array

2011-07-18 Thread Nishant Mittal
ok then 1st remove duplicates from the array in O(n) then apply my algo... On Mon, Jul 18, 2011 at 6:13 PM, ankit sambyal ankitsamb...@gmail.comwrote: @Nishant: Read the question carefully. It says Each number is present at least once except for 2 numbers. -- You received this message

Re: [algogeeks] Re: Missing Number in an array

2011-07-18 Thread Nishant Mittal
@SkRiPt KiDdIe... I think you need to analyze my algo again it will work for both the cases... On Mon, Jul 18, 2011 at 6:33 PM, SkRiPt KiDdIe anuragmsi...@gmail.comwrote: Nishant. Your algorithm works for finding repeated nos. in a [n+2] array where [1-n] are present atleast once

Re: [algogeeks] Re: Missing Number in an array

2011-07-18 Thread Nishant Mittal
@ankit for removing duplicates=O(n)+O(n) On Mon, Jul 18, 2011 at 6:36 PM, ankit sambyal ankitsamb...@gmail.comwrote: @nishant : Time complexity ?? will increase too much -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post

Re: [algogeeks] Re: Missing Number in an array

2011-07-18 Thread Nishant Mittal
and for finding missing 2 elements= O(n)+O(n)+O(n)+O(n) so total will be O(n) but there will be no overflow On Mon, Jul 18, 2011 at 6:41 PM, Nishant Mittal mittal.nishan...@gmail.comwrote: @ankit for removing duplicates=O(n)+O(n) On Mon, Jul 18, 2011 at 6:36 PM, ankit sambyal

Re: [algogeeks] Re: Missing Number in an array

2011-07-18 Thread Nishant Mittal
@SkRiPt KiDdIe... see my 3rd post...i've mentioned that 1st we have to remove duplicate numbers On Mon, Jul 18, 2011 at 6:56 PM, SkRiPt KiDdIe anuragmsi...@gmail.comwrote: @Nishant: 1 4 5 4 5n=5 1 2 3 4 5 after xor i.e. your x1 answer contains (2^3^4^5).The missing elements

Re: [algogeeks] Fwd: MICROSOFT INTERNSHIP (Coding round)

2011-07-18 Thread Nishant Mittal
start from top right corner... if a[i][j] x then move left, else if a[i][j] x then move down and if a[i][j] == x then print i and j On Mon, Jul 18, 2011 at 11:30 PM, sivaviknesh s sivavikne...@gmail.comwrote: -- Forwarded message -- From: sivaviknesh s

Re: [algogeeks] OUTPUT

2011-07-18 Thread Nishant Mittal
value of the static variable persists between different function call On Mon, Jul 18, 2011 at 11:43 PM, geek forgeek geekhori...@gmail.comwrote: int main() { static int var = 5; printf(%d ,var--); if(var) main(); } y output is 5 4 3 2 1 not 5 5 5 5 5 5 5 5 5

Re: [algogeeks] ms ques

2011-07-18 Thread Nishant Mittal
1st convert base 5 to base 10 and then base 10 to base 9 On Mon, Jul 18, 2011 at 11:54 PM, sivaviknesh s sivavikne...@gmail.comwrote: convert a number in base 5 to base 9 -- Regards, $iva -- You received this message because you are subscribed to the Google Groups Algorithm

Re: [algogeeks] Reverse a List with Recursion

2011-07-17 Thread Nishant Mittal
void rev_recursion(NODE **head) { if(*head==NULL) return; NODE *first, *rest; first=*head; rest=first-next; if(!rest) return; rev_recursion(rest); first-next-next=first; first-next=NULL; *head=rest; } On Sun, Jul 17, 2011 at 2:53 PM, vaibhav shukla

Re: [algogeeks] MICROSOFT

2011-07-17 Thread Nishant Mittal
take 2 arrays before and after... before[i] contains the product of all the numbers before i and after[i] contains product of all the numbers after i something like this before[0]=1; after[n-1]=1; for(i=1;in;i++) { before[i]=a[i-1]*before[i-1];

Re: [algogeeks] MS question

2011-07-17 Thread Nishant Mittal
1.while typing it must show most popular searches starting from the string which we have typed so far 2.it must show most popular websites first 3.it must show related searches there can be many more On Sun, Jul 17, 2011 at 8:05 PM, swetha rahul swetharahu...@gmail.comwrote: Write

[algogeeks] Re: MS question

2011-07-17 Thread Nishant
1.If string is NULL then it should return 1 i.e. string is palindrome 2.If there is only one character in string then it is palindrome 3.If reverse of given string is same as string On Jul 17, 8:18 pm, swetha rahul swetharahu...@gmail.com wrote: ya got it..thanks... how abt test cases for

Re: [algogeeks] MS:Linked list

2011-07-16 Thread Nishant Mittal
will be O(n) this won't work for large numbers... On Sat, Jul 16, 2011 at 1:58 AM, Nishant Mittal mittal.nishan...@gmail.com wrote: @sagar... I know this solution but it was strictly asked to do in O(n) time and O(1) space complexity and what if range of numbers is very large

Re: [algogeeks] C OUTPUT AGAIN

2011-07-16 Thread Nishant Mittal
value of b = 10 (in binary) and since b is a signed integer and also MSB is 1 so final value of b is 2's complement of 10 i.e. -2 On Sun, Jul 17, 2011 at 12:55 AM, Kamakshii Aggarwal kamakshi...@gmail.comwrote: @gaurav :y it is -2?y not +2? On Sat, Jul 16, 2011 at 2:13 PM, sukhmeet singh

[algogeeks] Linked list

2011-07-15 Thread Nishant Mittal
delete all the numbers found in list2 from list1 recursively or iteratively Also optimize ur algo when list1 is sorted in ascending order and list2 is sorted in descending order -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] MS:Linked list

2011-07-15 Thread Nishant Mittal
How will you delete duplicate odd numbers from a linked list in O(n) time -- 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] MS:Linked list

2011-07-15 Thread Nishant Mittal
to do it in O(n)... rather not even in O(nlogn) without modifying the list On Fri, Jul 15, 2011 at 11:23 PM, Nishant Mittal mittal.nishan...@gmail.com wrote: How will you delete duplicate odd numbers from a linked list in O(n) time -- You received this message because you are subscribed

Re: [algogeeks] Linked list

2011-07-15 Thread Nishant Mittal
number of elements from both lists and reverse list with minimum number of elements, go ahead with checking and deleting linearly surender On Fri, Jul 15, 2011 at 10:38 PM, Nishant Mittal mittal.nishan...@gmail.com wrote: delete all the numbers found in list2 from list1 recursively

[algogeeks] Re: Constructing a Binary Search Tree from Post Order traversal-Possible or not

2011-06-30 Thread Nishant
if BST contains integers then sort the postorder traversal which will give you inorder traversal... On Jun 30, 6:27 pm, oppilas . jatka.oppimi...@gmail.com wrote: Is it possible to create a binary search tree (not binary tree) from post order traversal only? If give, how and if not please give

[algogeeks] linked list

2011-06-29 Thread Nishant Mittal
segregate even and odd nodes in a singly linked list.Order of even and odd numbers must be same... e.g:- i/p list is 4-1-3-6-12-8-7-NULL o/p list 4-6-12-8-1-3-7-NULL -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

[algogeeks] BST

2011-06-29 Thread Nishant Mittal
how to find kth smallest element in BST... -- 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 algogeeks+unsubscr...@googlegroups.com.

[algogeeks] Re: Explain the o/p

2011-06-29 Thread Nishant
in 1st printf no. of characters written are 3 and 4 and 3 4 is 0 which is equal to i next 3 printf are easy... now in last printf no. of characters written by 2 printf(s) are 3 and 3 and 3 3 is 3 which is printed by outer printf On Jun 29, 7:40 pm, ashwini singh asingh...@gmail.com

[algogeeks] Re: linked list

2011-06-29 Thread Nishant
On Wed, Jun 29, 2011 at 8:18 PM, Nishant mittal.nishan...@gmail.com wrote: @sunny plz tell me the solution without using extra list...i've solved it using extra list... On Jun 29, 7:38 pm, sunny agrawal sunny816.i...@gmail.com wrote: maintain two pointers one at the tail of even number list one

[algogeeks] OS

2011-06-27 Thread Nishant Mittal
plz recommend me some good sites for OS interview questions... Thanx in advance -- 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] given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread Nishant Mittal
do inorder traversal of tree and store values in an array. Now find pairs by applying binary search on array.. On 6/27/11, manish kapur manishkapur.n...@gmail.com wrote: -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this

[algogeeks] MS question

2011-06-27 Thread Nishant Mittal
WAP to sort an array of character strings on the basis of last character of each string eg:- {xxxc , yyya, zzzb} = {yyya , zzzb, xxxc} -- 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] given a bst and a value x.find pair of nodes in the tree that sum upto x

2011-06-27 Thread Nishant Mittal
space On Mon, Jun 27, 2011 at 1:40 AM, Nishant Mittal mittal.nishan...@gmail.com wrote: do inorder traversal of tree and store values in an array. Now find pairs by applying binary search on array.. On 6/27/11, manish kapur manishkapur.n...@gmail.com wrote: -- You received

Re: [algogeeks] strings

2011-06-22 Thread Nishant Mittal
@Harshal... ur solution is nt correct.it is nt printing the characters in order as given in i/p... i know the solution using auxiliary array and using an extra character array to hold the o/p string but if any1 knows inplace solution then plz rply... On 6/22/11, Harshal hc4...@gmail.com wrote:

Re: [algogeeks] OS

2011-06-19 Thread Nishant Mittal
It does *not* prevent deadlock so i think (D) is definitely true. On Sun, Jun 19, 2011 at 5:15 PM, Akshata Sharma akshatasharm...@gmail.comwrote: Two processes, P1 and P2, need to access a critical section of code. Consider the following synchronization construct used by the processes: /* P1

[algogeeks] Explain the o/p

2011-06-15 Thread Nishant Mittal
//Prog 1 #includestdio.h int main() { float a=75.7; printf(%.10f\n,a); //prints 75.669482 if(75.7a) printf(Hi); else printf(Hello); return 0; } //Prog 2 #includestdio.h int main() { float a=275.7; printf(%.10f\n,a);//prints 275.7000122070 *WHY???* if(275.7a) printf(Hi); else

[algogeeks] Re: C OUTPUT

2011-05-22 Thread Nishant
conversion frm int to float and float to int is very poor in case of printf funtion so when we give the input to t then that value is displayed for all the printf function since %f modifier doesn't accept x (int) as a successful argument so it takes the latest float value.. On May 22, 2:41 pm,

Re: [algogeeks] Print Hello infinite..................

2011-03-09 Thread Nishant Agarwal
#includestdio.h void print1(); void print2() { printf(Hello\n); print1(); } void print1() { printf(Hello\n); print2(); } int main() { print1(); } On Thu, Mar 10, 2011 at 11:47 AM, nidhi jain nidhi.jain311...@gmail.comwrote: @abhishek:isn't it recursion? -- You

[algogeeks] Explain the o/p

2011-03-04 Thread Nishant Agarwal
#includestdio.h main() { long x; float t; scanf(%f,t); printf(%d\n,t); x=90; printf(%f\n,x); { x=1; printf(%f\n,x); { x=30; printf(%f\n,x); } printf(%f\n,x); } x==9; printf(%f\n,x); }

Re: [algogeeks] Re: printing without loop

2011-03-01 Thread Nishant Agarwal
use recursion. On Tue, Mar 1, 2011 at 5:13 PM, bittu shashank7andr...@gmail.com wrote: here we go void main() { int i; i=1; loop: printf(%d, i) (i100)? i++: return 0; go to loop; } Thanks Regards Shashank Mani The Best Way to Escape From The Problem is to Solve it --

Re: [algogeeks] Re: arrays

2010-09-28 Thread Nishant Agarwal
#includestdio.h #includestdlib.h int main() { int a[20],i,n,max,t,j,k; printf(Enter the no. of elements\n); scanf(%d,n); for(i=0;in;i++) scanf(%d,a[i]); for(i=0;in-1;i++) { j=n-1; max=0; k=i; while(ij) {

Re: [algogeeks] Re: Number problem

2010-09-25 Thread Nishant Agarwal
...@googlegroups.comalgogeeks%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en. -- :-) * Nishant Agarwal Computer Science and Engineering NIT Allahabad

Re: [algogeeks] Re: Number problem

2010-09-25 Thread Nishant Agarwal
. -- :-) * Nishant Agarwal Computer Science and Engineering NIT Allahabad * -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email

  1   2   >