Re: [algogeeks] Openings in Flipkart BLR

2015-09-05 Thread Amit Tiwari
Hi, What are the minimum qualifications for APM position? Amit Tiwari On Sep 1, 2015 9:38 PM, "Sachin Chitale" <sachinchital...@gmail.com> wrote: > Hi folks, > > There are following open position in flipkart if someone is interested do > send your resume. > &g

[algogeeks] Need help on SPOJ(HASHIT)

2013-05-27 Thread Amit
Hello, I have been trying to solve this http://www.spoj.com/problems/HASHIT/problem on SPOJ. I am getting Wrong Answer on submission, but my solution work fine on the sample. Please tell me where I am wrong. Here http://ideone.com/lMSw94 is my code. Thanks in advance. Amit Tiwari BIT Mesra

Re: [algogeeks] sortin 2D array

2013-01-08 Thread Amit Basak
Take a one dimensional array as the multiplication of both the dimensions of the two dimensional array and copy the two dimensional array elements in the one dimensional array. After that use an efficient sorting (e.g. quick sort) on this one dimensional array Regards, - Amit

Re: [algogeeks] Resources for understanding Dynamic programming

2012-11-17 Thread Amit Tiwari
Try to read 'Introduction to Algorithms' by CLRS. Also there are videos available for that course in the MIT's Open Course-ware. The concepts are explained very nicely. There are also some good tutorials of dynamic programming on the topcoder. Hope it helps. On Thu, Nov 15, 2012 at 4:01 PM,

Re: [algogeeks] Re: INTERFACES VS ABSTRACT

2012-08-23 Thread Amit Tiwari
With an abstract class, the subclass of that inheritance tree only can and should provide the definitions of the methods. With an interface, subclasses of different inheritance tree can also implement the same methods. Interface provides a way to separate out and group common behavior of different

Re: [algogeeks] Microsoft first round interview question.

2012-08-02 Thread Amit Basak
Does each node in the list have three pointers? What do you mean by straight doubly link list? Thanks, Amit On Wed, Aug 1, 2012 at 7:25 PM, sahil gupta sahilgupta...@gmail.com wrote: There is doubly link list and each node is having another pointer which is points to another doubly link

Re: [algogeeks] directi paper pattern

2012-07-31 Thread amit singh
hi shaukat Ali ,it will be really kind if you can forward me that paper of directi my ID:amitsingh...@gmail.com On Tuesday, 31 July 2012 21:42:43 UTC+5:30, md shaukat ali wrote: On Tue, Jul 31, 2012 at 7:37 PM, deepikaanand swinyanand...@gmail.comwrote: can anyone tell me the pattern

Re: [algogeeks] adobe aptitude test

2012-07-26 Thread Amit Jain
I assumed, You were called for Interview off-campus. It depends upon the profile You have been called for. BTW it was too easy for White box testing. On Wed, Jul 25, 2012 at 8:13 PM, deepikaanand swinyanand...@gmail.comwrote: can anybody tell me which topics are asked in adobe apti test...and

[algogeeks] Re: Question asked in Amazon online test

2012-07-24 Thread Amit
Let's define a term RANDOMNESS of array as... summation of position of each 1's for eg RANDOMNESS for (0,0,1,0,1,0,1,1) will be 23 now calculate max possible RANDOMNESS for the given array (each 1 on max possible right position) here it will be 26 so ans will be-- MAX RANDOMNESS of given array

Re: [algogeeks] Crawler/perl/php/database help

2012-07-20 Thread Amit Jain
Hi Is your crawler script in python or shell script? Thanks Amit Jain On Fri, Jul 20, 2012 at 6:02 AM, Nandita Raman nandita.rama...@gmail.comwrote: Hello, I am working on a unix machine. and i have the crawler script with me. The task i need to do is, update my database (by creating

[algogeeks] Re: How to get First D digits of a pow(N,N)

2012-07-20 Thread Amit Jain
Any thought? On Tue, May 15, 2012 at 11:46 AM, Amit Jain aj201...@gmail.com wrote: Hi All How can we get first D digits of N to the power N ? P.S. N is of order 10^18 (^ : Power) and D = N Thanks Amit Jain -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] Re: Directi Interview Ques

2012-07-17 Thread Amit Jain
Awesomely done :) +1 On Mon, Jul 16, 2012 at 2:15 AM, Anshu Mishra anshumishra6...@gmail.comwrote: two arrays are suppose x[n], y[n]; take a function f( x(i, n), y(j, n) , 0) -- taking x[i] as a first element of merged array then max sum; f( x(i, n), y(j, n), 1) -- taking y[j] as a first

Re: [algogeeks] Re: Directi Interview Ques

2012-07-17 Thread Amit Jain
Please see *stable merge *in question. On Sun, Jul 15, 2012 at 2:04 AM, sengar.mahi sengar.m...@gmail.com wrote: @naveen : 3*7+2*9+1*3 =42 is not maximum.. sum of the product would me maximum wen, i guess, most weighted elements are adjacent like in this case if c={1,2,3,3,7,9} 1*2 + 3*3 +

Re: [algogeeks] A Coding Problem

2012-07-16 Thread Amit Jain
+1 On Sat, Jul 14, 2012 at 8:14 PM, saurabh singh saurab...@gmail.com wrote: its from a running contest i believe.This is against the group policy as well as against the ethics of programmers. The author of this post is banned permanently from algogeeks. Kindly no more posts on this thread

Re: [algogeeks] Re: microsoft

2012-07-16 Thread Amit Jain
No It will not. For negative number, it will fail. On Sun, Jul 15, 2012 at 11:45 PM, Tanuj Makkar tanujmakkar.de...@gmail.comwrote: double round(double num) { return (int)(num+0.5) } will it work all the time? .. didnt get itcan anyone explain it.thnx in advance.

Re: [algogeeks] Abridged summary of algogeeks@googlegroups.com - 10 Messages in 8 Topics

2012-06-25 Thread amit singh
sourabh singh, i think problem in your code may arise due to term (m/a -n/a) ,instead it should be m/a -(n-1)/a . there may be some other problem also .but this can be one of them On Mon, Jun 25, 2012 at 5:10 PM, algogeeks@googlegroups.com wrote:   Today's Topic Summary Group:

Re: [algogeeks] adarsh kumar wants to chat

2012-05-23 Thread Amit Tiwari
I have added you on gtalk. On 5/22/12, adarsh kumar algog...@gmail.com wrote: --- adarsh kumar wants to stay in better touch using some of Google's coolest new products. If you already have Gmail or Google Talk, visit:

[algogeeks] How to get First D digits of a pow(N,N)

2012-05-15 Thread Amit Jain
Hi All How can we get first D digits of N to the power N ? P.S. N is of order 10^18 (^ : Power) and D = N Thanks Amit Jain -- 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] Re: storing URL's

2012-05-15 Thread Amit Mittal
/algogeeks?hl=en. -- Regards Amit Mittal -- 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

Re: [algogeeks] algorithm that returns number of internal nodes in the tree

2012-05-09 Thread Amit Jain
Here is my version Algorithm count(x) 1: if (x==nil || (left[x]== nil and right[x]==nil)) 2: return 0 3: return count(left[x]) + count(right[x]) +1 Time Complexity: O(n) where is n is total number of node in tree. Thanks On Wed, May 9, 2012 at 11:17 AM, Akshay Rastogi akr...@gmail.com

Re: [algogeeks] Explain the code

2012-03-20 Thread Amit Kumar
@sajal I mean the same. Warm Regards Amit Kumar Master Of Computer Applications University Of Delhi -- 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

[algogeeks] Share your comments

2012-02-10 Thread Amit Garg
I was studying the algorithm behind gold and currency that is running for ages on Earth. So I though I would share it with algo geeks: http://lunaticzombie.blogspot.in/2011/12/barter-to-gold-to-currency-to-barter.html do share your comments -- You received this message because you are

Re: [algogeeks] Re: virtual destructor problem

2011-12-08 Thread Amit Basak
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. -- Thanks, Amit Kumar Basak -- You received this message

Re: [algogeeks] virtual destructor problem

2011-12-07 Thread Amit Basak
will have two lines output as baseClass Des called baseClass Des called This is why it is always advisable to make the destructor as virtual. Amit On Wed, Dec 7, 2011 at 3:27 PM, Prem Krishna Chettri hprem...@gmail.comwrote: The Output would be only the base class object destructor would be called

Re: [algogeeks] Link list Q

2011-12-01 Thread Amit Chauhan
Option (c) is correct. detects the loop in singly linked list ** On Thu, Dec 1, 2011 at 1:42 PM, Vijay Khandar vijaykhand...@gmail.comwrote: What does the following program do on the singly linked list? p=head; q=head-next; while(p!=null q!null) { if(p==q) { exit(0) } p=p-next;

[algogeeks] Dbms

2011-10-06 Thread amit kannaujiya
Any one having good material on functional dependency and normalization , which contain examples and easily explain these concepts ... Plz post here ... -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to

[algogeeks] oracle finance questions

2011-10-03 Thread amit kannaujiya
if any one know regarding oracle finance online test, plz post type of questions asked in online test . -- 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

Re: [algogeeks] request of ebook..(Data Structures and algorithms made easy:)

2011-09-26 Thread Amit Mittal
plz send me that book too On Mon, Sep 26, 2011 at 3:28 PM, Ishan Aggarwal ishan.aggarwal.1...@gmail.com wrote: plz send me that book to I also need that book... On Sun, Sep 25, 2011 at 9:37 PM, sarath prasath prasathsar...@gmail.comwrote: hi every one.. pls do give me the link

Re: [algogeeks] Re: sqrt function...

2011-09-25 Thread Amit Mittal
double sqrt(double c) { if (c 0) return error; double err = 1e-15; double t = c; while (fabs(t*t - c) err) t = (c/t + t) / 2.0; return t; } On Sun, Sep 25, 2011 at 2:57 PM, teja bala pawanjalsa.t...@gmail.comwrote: @vikram the one which i posted(link) it was newton raphson method which

[algogeeks] Re: microsoft interview

2011-09-09 Thread Amit Gupta
' Also, don't do anything if you encounter a '1'. 3. Goto 1. 4. Scan the array, change all '-1s' to 1s. Finish. Send your comment. Cheers, Amit -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send email to algogeeks

[algogeeks] Re: Adobe written test

2011-09-08 Thread Amit Gupta
Written test of adobe had 3 sections - Quant and Analytical section - 45 questions(30 + 15) 45 mins 2 coding papers - 1 hr each , 10 ques each 1st coding paper had general MCQ (test ur c skills type ) 2nd coding paper had ques for writing algos, codes and few OS questions. -- You received this

Re: [algogeeks] puzzle

2011-09-04 Thread amit kannaujiya
1) on one switch for some time . then , off that switch. 2) Now on a switch , and open the door. the bulb which is on , that is for that switch . earlier on switch will be for that bulb ,which is hot . and the third switch will be for that bulb which coolest On Sun, Sep 4, 2011 at 12:30 PM,

Re: [algogeeks] Book Request Data Structures and Algorithms Made Easy

2011-09-03 Thread Amit Mittal
Please upload this book, if anyone of you have it. On Fri, Aug 19, 2011 at 7:59 AM, Swati Sarraf swati1...@gmail.com wrote: Hey Navneet , which book are you talking abt- Data structure and algo made easy OR Data structure Puzzles ?

Re: [algogeeks] Book Request Data Structures and Algorithms Made Easy

2011-09-03 Thread Amit Mittal
Rahul, This is not the complete book, it has just two chapters. Can you provide a link for the entire book ? On Sat, Sep 3, 2011 at 6:28 PM, Rahul Verma rahulverma@gmail.comwrote: download the book from:

[algogeeks] Re: Find the Max from each sub-array of size k

2011-09-02 Thread amit chandel
we can do it using max heap -- 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. For more

Re: [algogeeks] Re: reverse

2011-08-25 Thread amit kannaujiya
int reverse(int n) { int i=9*( abs(n/10 - n%10) ); return i; } On Wed, Aug 24, 2011 at 9:56 PM, Dave dave_and_da...@juno.com wrote: @Anika: So you want to reverse the digits of the decimal representation of a number. Extracting decimal digits requires division and modulus by 10.

Re: [algogeeks] Re: reverse

2011-08-25 Thread amit kannaujiya
On Thu, Aug 25, 2011 at 7:58 PM, amit kannaujiya amitkannaujiyan...@gmail.com wrote: int reverse(int n) { int i=9*( abs(n/10 - n%10) ); i=i+n; return i; } On Wed, Aug 24, 2011 at 9:56 PM, Dave dave_and_da...@juno.com wrote: @Anika: So you want to reverse the digits

Re: [algogeeks] Accessing private members of Derived class ?

2011-08-22 Thread Amit Mittal
This might help http://publib.boulder.ibm.com/infocenter/comphelp/v8v101/index.jsp?topic=%2Fcom.ibm.xlcpp8a.doc%2Flanguage%2Fref%2Fcplr130.htm \ On Mon, Aug 22, 2011 at 11:40 AM, Sanjay Rajpal srn...@gmail.com wrote: Here concept of v-tables comes into picture. Refer to C++ Primer Plus by

[algogeeks] Re: Trees

2011-08-11 Thread amit karmakar
5 is possible. Considering root of the tree to be at level 0, level 1 and level 2 are completely filled. There are 5 internal nodes in level 1, (since all level 2 nodes are present) Now only (10 - 5(from level 1)+1(the root)) nodes are required. So choose 4 nodes from level 2 and make them

[algogeeks] Re: Trees

2011-08-11 Thread amit karmakar
I tried solving this problem and came to conclusion that none of the options can be correct. Indeed for value 5, you can have a solution. Then i googled for this question, and found out that, you have an option missing. i.e 5 :| On Aug 11, 9:01 pm, rajeev bharshetty rajeevr...@gmail.com wrote:

[algogeeks] Re: Trees

2011-08-11 Thread amit karmakar
* correction (5*5(There are 5*5 nodes in level 2)-4(These became internal nodes..)) On Aug 11, 9:58 pm, amit karmakar amit.codenam...@gmail.com wrote: 5 is possible. Considering root of the tree to be at level 0, level 1 and level 2 are completely filled. There are 5 internal nodes in level

[algogeeks] Re: ~ operator

2011-08-10 Thread amit karmakar
calculate 0101+1001+1 as Now if the signed numbers are represented using 2's complement system then is the representation for -1 On Aug 10, 7:23 pm, Ayswarya Srinivasan krsayswa...@gmail.com wrote: can someone explain how this works- * * *void* *main*(){     *int* a,b,d;    

[algogeeks] Re: pre-post decrement

2011-08-08 Thread amit karmakar
z=(--i)--; It works fine only with a c++ compiler not C. preincrement operator -- doesn't yield a lvalue in case of C. will have different On Aug 8, 11:01 pm, raj kumar megamonste...@gmail.com wrote: @jagrati so why it works fine z=(--i)--; -- You received this message because you are

[algogeeks] Re: SPOJ ABCD

2011-08-07 Thread amit karmakar
@amol I got accepted using the similar approach. But i performed backtracking. In each step of backtracking i chose the next option as you done. So, there can be cases where this approach fails. Runtime error may occur because,

[algogeeks] Re: Sum from array

2011-08-07 Thread amit karmakar
It can be reduced to subset sum problem. So I cannot see O(n) being possible here. Even the dynamic programming approach(provided there are some more constraints for this problem) is O(n*m) where m is related to the range of values of sum. On Aug 7, 2:10 pm, swetha rahul swetharahu...@gmail.com

[algogeeks] Re: nlogn, in-place, iterative mergesort?

2011-08-07 Thread amit karmakar
The best thing is that you don't need explicit stacks for removing recursion. A couple of loops can do the job. On Aug 6, 9:57 pm, immanuel kingston kingston.imman...@gmail.com wrote: Yes. just remove the recursive part using 2 stacks. Thanks, Immanuel On Fri, Aug 5, 2011 at 6:51 PM, Nitin

[algogeeks] Re: nlogn, in-place, iterative mergesort?

2011-08-07 Thread amit karmakar
to tell anything more than that. :) On Aug 7, 3:07 pm, DK divyekap...@gmail.com wrote: @Amit and @Immanuel: You're not getting the point. Merge sort is not in-place because it requires an extra O(N) array during the merge step. The problem asks not to remove the recursive nature of the merge-sort

[algogeeks] Re: Longest matching substring

2011-08-06 Thread amit karmakar
For other algorithms have a look here, http://en.wikipedia.org/wiki/Longest_common_substring_problem On Aug 6, 1:55 pm, payel roy smithpa...@gmail.com wrote: Trie .. On 6 August 2011 14:24, Mukul Gupta mukul.gupta...@gmail.com wrote: Yes, vikash is right. This will work. Works in

[algogeeks] Re: Longest matching substring

2011-08-06 Thread amit karmakar
I think there is some error in this implementation, On Aug 6, 1:54 pm, Mukul Gupta mukul.gupta...@gmail.com wrote: Yes, vikash is right. This will work. Works in O(nm). http://ideone.com/G6RAK On Sat, Aug 6, 2011 at 1:30 PM, vikash vikash.ckiiit...@gmail.com wrote: apply longest

[algogeeks] Re: Global Scholar

2011-08-06 Thread amit karmakar
I only know about the telephonic interview round which was of around 30 minutes. They asked three algorithmic problems, 1. For a given binary tree where each node has a integer value associated with it. Write a program that takes k as input and prints the sum of all nodes after level k. 2.

[algogeeks] Re: Printf

2011-08-05 Thread amit karmakar
Invokes undefined behavior.! On Aug 5, 12:47 pm, Aman Goyal aman.goya...@gmail.com wrote: physical address i suppose... On Fri, Aug 5, 2011 at 1:09 PM, anurag anurag19aggar...@gmail.com wrote: What will be the output. int i=5; printf(%u,i); What it will print: i. 5 ii. Base

[algogeeks] Re: remove duplicate words in a string

2011-08-05 Thread amit karmakar
Using a trie data structure this can be solved in O(n). read each character of the input string and build a trie. Maintain the counts of all words. Now traverse the trie again with the input string and making decisions whether to print a string depending on the word count that you get from the

Re: [algogeeks] Samsung SISO Question

2011-08-05 Thread amit kumar
can u plz xplain d qstn a litl more thanx On Fri, Aug 5, 2011 at 8:33 PM, bagaria.ka...@gmail.com bagaria.ka...@gmail.com wrote: Given a rope of 10m , numbered at 1m i.e like 0 1 2 3 4 5 6 7 8 9 10 ||---|---|---|---|---|---|---|---|---| |---10m|

[algogeeks] Google Interview preparation

2011-08-04 Thread Amit Mittal
I have my google interview at the end of this month. can any body provide me some tips/suggestions/questions ? I am sure some of you guys here must have appeared in google interviews before, your help will be very valuable and much appreciated. Thanks -- You received this message because you

[algogeeks] Re: merging of two sorted arrays

2011-08-04 Thread Amit
Consider two array arr_a[] and arr_b[]. Suppose Number of elements in arr_a[] are n and number of elements in arr_b[] are m. size of arr_a[] is n and size of arr_b[] is m. MergeInPlace(int arr_a[], int arr_b[],int n,int m) { int a =0;b=0,k=0,key=0; for(;bm;b++){ for(;an;a++){

[algogeeks] Re: C++ doubt

2011-08-04 Thread Amit
exception, because dynamic_cast does runtime type checking. Regards, Amit -- 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

[algogeeks] Re: Minimum cuts required so that each sub string is a palindrome

2011-08-03 Thread amit karmakar
Let the given string have a length N and contain characters indexed from 1 on to N. Let, f(n) denote the minimum number of cuts that you need to make such that each substring is a palindrome, considering only the prefix containing n characters. f(0) = -1 f(n) = min( f(x) + 1 ), take x such that

[algogeeks] Re: C question.. increment decrement operator..

2011-08-03 Thread amit karmakar
You are wrong. The above program invokes undefined behavior. Read the standard language draft to know about sequence points, side effects and undefined behavior. Between a previous and next sequence point a variable's value cannot be modified twice. c-faq should be quite useful

[algogeeks] Re: Minimum cuts required so that each sub string is a palindrome

2011-08-03 Thread amit karmakar
++) { if(pre[x][i]) { dp[i] = min(dp[i], (x==0)?0:(dp[x-1]+1)); } } } printf(%d\n, dp[n-1]); } It may contain errors, i haven't tested it properly... On Aug 3, 9:12 pm, ankit sambyal ankitsamb...@gmail.com wrote: @amit: can u supply the code for ur approach

[algogeeks] Re: Give an efficient search algo

2011-08-03 Thread amit karmakar
I think for question 1, the value of k is not provided, right? On Aug 4, 12:53 am, Ankur Garg ankurga...@gmail.com wrote: Dave's solution looks gud to me :) On Wed, Aug 3, 2011 at 3:52 PM, Ankur Garg ankurga...@gmail.com wrote: Q1 can be looked as rotated sorted array...check whether the

[algogeeks] Re: Give an efficient search algo

2011-08-03 Thread amit karmakar
Can you show how to find k for an array containing n 2's using binary search. On Aug 4, 6:29 am, Dave dave_and_da...@juno.com wrote: @Amit: If k is not known, you can find it with another binary search. Dave On Aug 3, 3:02 pm, amit karmakar amit.codenam...@gmail.com wrote: I think

[algogeeks] Re: SEGMENT TREE: WA

2011-08-02 Thread amit karmakar
Do you understand the problem properly ? From your code it seems you don't understand the problem. Can you explain the approach that you have implemented? On Aug 2, 5:13 pm, Amol Sharma amolsharm...@gmail.com wrote: anyone ?? -- Amol Sharma Third Year Student Computer Science and

[algogeeks] Re: interview questoin

2011-07-31 Thread Amit Jaspal
This is discussed before I think. It will be in O(n). On Jul 31, 1:15 pm, siva viknesh sivavikne...@gmail.com wrote: using map ?? key - string , value - count..print d string whose count is 1.. On Jul 19, 8:49 pm, pacific :-) pacific4...@gmail.com wrote: sorry. On Tue, Jul 19,

[algogeeks] Re: 100th Fibonacci number using LL

2011-07-31 Thread amit karmakar
Since long long cannot store the 100th Fibonacci number, you need to implement or use an existing library for bignum. You may use linked lists to solve this problem. Read about bignum here http://en.wikipedia.org/wiki/Arbitrary-precision_arithmetic Here is my implementation for solving this

[algogeeks] Re: Subsequence with Sum S

2011-07-30 Thread amit karmakar
This can be reduced to the standard subset sub problem. For algorithms to solve it consider reading about it here, http://en.wikipedia.org/wiki/Subset_sum_problem This is my implementation for solving this problem provided the range of values that the array can take is small(from 0 to MXSUM-1

[algogeeks] Re: permutation of string with repeated characters...

2011-07-29 Thread amit karmakar
string aabc and explain a few steps that happen from your code??.The array mk is locally created for each function call and so I do not get how it keeps track of elements tried cos each time it is a new array. On Fri, Jul 29, 2011 at 3:54 AM, amit karmakar amit.codenam...@gmail.comwrote

[algogeeks] Re: permutation of string with repeated characters...

2011-07-29 Thread amit karmakar
you take your example string aabc and explain a few steps that happen from your code??.The array mk is locally created for each function call and so I do not get how it keeps track of elements tried cos each time it is a new array. On Fri, Jul 29, 2011 at 3:54 AM, amit karmakar amit.codenam

[algogeeks] Re: permutation of string with repeated characters...

2011-07-29 Thread amit karmakar
there was an typo, if mk array is *not* there backtracking will try like On Jul 29, 7:13 pm, amit karmakar amit.codenam...@gmail.com wrote: The seen array filters out the characters which are available for filling a particular position. The mk array makes sure that we choose only one

[algogeeks] Re: adobe written round que

2011-07-29 Thread Amit
well,well,well... a=x1; b=x2; c=(a+b)1; d=x3; x=c+d; actually i used the fact- 1/3 = 3/9 = ((1/2)+(1/4))/2 + 1/8 On Jul 30, 1:37 am, nivedita arora vivaciousnived...@gmail.com wrote: hmm ok got it . ..i can take gt sum of digits without having the number as string as well . i din exactly gt

[algogeeks] Re: Facebook Interview question at NIT Warangal

2011-07-28 Thread amit
This should be O(2^n) #include cstdio #include cstring using namespace std; int n; int sol[1000]; void solve(int pos, int k) { for(int i = 0; i k; i++) printf(%d, , sol[i]); putchar('\n'); for(int i = pos; i n; i++) { sol[k] = i+1; solve(i+1, k+1); } } int

[algogeeks] Re: Facebook Interview question at NIT Warangal

2011-07-28 Thread amit karmakar
I am wrong about the complexity. Its O(n*2^n). @amitno it wont work..check it.. My code generates all subsets of a set containing elements from 1 to n(inclusive). I was answering for ankur. Why won't it work ? On Jul 28, 1:39 pm, Piyush Sinha ecstasy.piy...@gmail.com wrote: @amit

[algogeeks] Re: Permutations in a string

2011-07-28 Thread amit karmakar
Yes, you are right. A slight modification is needed to handle repeated characters. I have already posted that in this group. https://groups.google.com/group/algogeeks/msg/afb18610819dbd90 On Jul 28, 10:56 pm, varun pahwa varunpahwa2...@gmail.com wrote: @amit:: I think ur solution will give wrong

[algogeeks] Re: permutation of string with repeated characters...

2011-07-28 Thread amit karmakar
What my recursive solution does is that, For all elements that can be used at position *k*, fix that element at position *k* and then permute the rest of the elements. So if are two same elements which can be used at position *k* we must choose only one of it to avoid repeated permutations. Array

[algogeeks] Re: Facebook Intern F2F Interview

2011-07-28 Thread Amit Gupta
I'm wondering if we should be using the rand() library function or the guy is expecting us to create a random function. y = rand( )%100; if(yx) return true; else return false; //is one of the probable solutions. -- You received this message because you are subscribed to the Google Groups

[algogeeks] Re: C output 2

2011-07-27 Thread amit
hello is a string literal and this is what the C standard says about string literals: The multibyte character sequence is then used to initialize an array of static storage duration and length just sufficient to contain the sequence. So memory will remain reserved for hello for the entire

[algogeeks] Re: Permutations in a string

2011-07-27 Thread amit
#include cstdio #include cstring using namespace std; const int MX = 1000; int n, k; char str[MX], partial[MX]; void solve(int pos, int aux) { if(aux==k) { partial[aux] = 0; printf(%s\n, partial); return; } for(int i = pos; i n; i++) { partial[aux]

[algogeeks] Re: rotate a matrix NVIDIA question

2011-07-27 Thread amit
#include cstdio #include algorithm using namespace std; const int MX = 1000; int n, m; int a[MX][MX]; int main() { scanf(%d%d, n, m); for(int i = 0; i n; i++) for(int j = 0; j m; j++) scanf(%d, a[i][j]); for(int i = 0; i n/2; i++) for(int j = 0; j m;

[algogeeks] Re: OUTPUT

2011-07-27 Thread amit
Hmm, I don't get the question. how to dynamically allocate memory for int *a[3]; ? What do you mean by allocating memory for int *a[3]; Can you explain in some more details what exactly you want to do On Jul 27, 8:39 pm, Kamakshii Aggarwal kamakshi...@gmail.com wrote: i am not getting any of

Re: Re : [algogeeks] sizeof() question.

2011-07-27 Thread amit karmakar
sizeof(main()) == sizeof(int) because main return integer. But main isn't invoked, sizeof does all thing at compile time. On Wed, Jul 27, 2011 at 9:27 PM, Charlotte Swazki charlotteswa...@yahoo.frwrote: No. it's wrong. sizeof(main()) == sizeof(int) because main return integer. i -

[algogeeks] Re: rotate a matrix NVIDIA question

2011-07-27 Thread amit karmakar
the above code is an O(n^2) solution.. if i am not wrong...!!! On 7/27/11, amit amit.codenam...@gmail.com wrote: #include cstdio #include algorithm using namespace std; const int MX = 1000; int n, m; int a[MX][MX]; int main() {     scanf(%d%d, n, m);     for(int i = 0; i n

[algogeeks] Re: Amazon Question

2011-07-27 Thread amit karmakar
http://en.wikipedia.org/wiki/Substring ac should be a subsequence and not substring. On Jul 28, 12:00 am, Kamakshii Aggarwal kamakshi...@gmail.com wrote: in the above example y ac is not included in the substring? On Wed, Jul 27, 2011 at 3:45 PM, saurabh singh saurab...@gmail.com wrote:

[algogeeks] Re: Amazon Question

2011-07-27 Thread amit karmakar
#include cstdio #include cstring using namespace std; const int MX = 1000; char str[MX], sol[MX]; bool seen[MX] = {0}; void print(int n, int k=0) { if(k==n) { sol[n] = 0; printf(%s\n, sol); return; } for(int i = 0; i n; i++) { if(!seen[i]) {

Re: [algogeeks] permutation of string with repeated characters...

2011-07-27 Thread amit karmakar
how to find all permutations of string with repeated characters.like aabc. idea is backtracking, complexity isn't very good #include cstdio #include cstring using namespace std; const int MX = 1000; char str[MX], sol[MX]; bool seen[MX] = {0}; void print(int n, int k=0) { if(k==n) {

[algogeeks] Re: C Doubts

2011-07-18 Thread Amit
1. In C, you cannot assign to a variable which is const, but in C++, there is a way to cast away constness of object/variable using const_cast. -- 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: amazon

2011-07-14 Thread Amit Gupta
I think Nitish is right. The output shoud be as mentioned by Nitish. And the code for that #includestdio.h int n; void f(int *,int,int,int); int main() { scanf(%d,n); int arr[n]; f(arr,0,0,0); getchar(); getchar(); return 0; } void f(int arr[], int open, int close, int

[algogeeks] Re: amazon

2011-07-14 Thread Amit Gupta
Just replace the 1's with { and 0's with } -- 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/-/H1GtxuX8Zq4J. To post to this group, send email to

[algogeeks] Re: Adding w/o +

2011-07-13 Thread Amit Gupta
You can try this also do { sum = a ^ b; carry = a b; a = sum; b = carry; }while (carry!=0); -- 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/-/KoeFGWuM71IJ.

[algogeeks] puzzle

2011-07-09 Thread amit the cool
find d next: 91,110,134,_ -- 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. For more options,

[algogeeks] puzzle

2011-07-09 Thread amit the cool
6,24,60,120,_ -- 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. For more options, visit this

[algogeeks] puzzle

2011-07-06 Thread amit the cool
Can you make a target number 37 by using five 5s? You can use any math operator as you want. There are at least two different ways. 5 5 5 5 5 -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] puzzle

2011-07-06 Thread amit kumar
thanx guys On Wed, Jul 6, 2011 at 2:40 PM, udit sharma sharmaudit...@gmail.com wrote: (5*5)+(!5)/(5+5) and (((5+5)/5)^5)+5 -- Regards UDIT DU- MCA -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To post to this group, send

Re: [algogeeks] Longest substring 0's 1's

2011-07-06 Thread amit kumar
excellent solution sunny On Tue, Jul 5, 2011 at 11:44 PM, amit kumar amitthecoo...@gmail.com wrote: #includestdio.h #define n 11 int main() { int ar[n]={1,0,1,1,1,0,0,0,0,0,1}; int a[n][n]; int l,i,k,maxlength=0,start,end; for(i=0;in;i++) { ar[i]==0?(a[i][i

Re: [algogeeks] find output

2011-07-04 Thread amit kumar
decrement and will be printed as -1. On Mon, Jul 4, 2011 at 3:54 PM, amit the cool amitthecoo...@gmail.comwrote: main() { int i=0; while(+(+i--)!=0) i-=i++; printf(%d,i); } output sud be 1 bt it is -1; why?? -- You received this message because you are subscribed to the Google

[algogeeks] find output

2011-07-03 Thread amit the cool
int main() { int a[]={5,10,15,8}; int *x=a; int y; y=*x++; printf(%d,y); } -- 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

Re: [algogeeks] find output

2011-07-03 Thread amit kumar
...@gmail.comwrote: 5 On Mon, Jul 4, 2011 at 1:01 AM, amit the cool amitthecoo...@gmail.comwrote: int main() { int a[]={5,10,15,8}; int *x=a; int y; y=*x++; printf(%d,y); } -- You received this message because you are subscribed to the Google Groups

Re: [algogeeks] null macro

2011-06-30 Thread amit kumar
no difference On Thu, Jun 30, 2011 at 11:24 PM, simran ngxprerna2...@gmail.com wrote: null macro is defined as #define NULL (void*)0..is there any difference in null macro definition in c and c++? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks

Re: [algogeeks] novel written test

2011-06-28 Thread amit kumar
ohh its a straight chain..nt a rounded one.. gt it On Tue, Jun 28, 2011 at 12:42 PM, sagar pareek sagarpar...@gmail.comwrote: @amit Check out your IQ On Tue, Jun 28, 2011 at 2:43 AM, amit kumar amitthecoo...@gmail.comwrote: how 2?? On Tue, Jun 28, 2011 at 2:40 AM, gmagog

[algogeeks] novel written test

2011-06-27 Thread amit the cool
Conversation between two mathematicians: first : I have three children. The product of their ages is 36 . If you sum their ages . it is exactly same as my neighbor's door number on my left. The second mathematician verifies the door number and says that the not sufficient . Then the first says

[algogeeks] novel written test

2011-06-27 Thread amit the cool
A chain is broken into three pieces of equal lengths containing 3 links each. It is taken to a back smith to join into a single continuous one . How many links are to be opened to make it ? -- You received this message because you are subscribed to the Google Groups Algorithm Geeks group. To

Re: [algogeeks] novel written test

2011-06-27 Thread amit kumar
@piyush..will u xplain plz. by d way 2 sons cant hav d same age(hope they r nt twins) On Tue, Jun 28, 2011 at 2:14 AM, Piyush Sinha ecstasy.piy...@gmail.comwrote: 1,6,6 On Tue, Jun 28, 2011 at 2:07 AM, amit the cool amitthecoo...@gmail.comwrote: Conversation between two mathematicians

  1   2   3   >