Re: [algogeeks] C o/p adobe

2012-10-24 Thread SHOBHIT GUPTA
http://www.geeksforgeeks.org/archives/840

By default, the declaration and definition of a C function have “extern”
prepended with them. It means even though we don’t use extern with the
declaration/definition of C functions, it is present there. For example,
when we write.

int foo(int arg1, char arg2);

There’s an extern present in the beginning which is hidden and the compiler
treats it as below.

extern int foo(int arg1, char arg2);


On Wed, Oct 24, 2012 at 4:40 PM, rahul sharma rahul23111...@gmail.comwrote:

 Pleaase reply with sol as asp

 Fille 1:
 #includestdio.h
 extern int i;

 extern int j;
 void next(void);
 int main()
 {
 ++i;
 printf(%d,i);
 next();
 getchar();
 }
 int i=3;
 void next()
 {
  ++i;
  printf(%d,i);
  printf(%d,j);
 other();
  }
 File 2:
 extern int i;

 void other()
 {
  ++i;
 printf(%d,i)'
 }

 How cum file 1 knows what is other();as we havnet define with
 extern void other();
 it should be error
 but when i include the statemetn extern void other,then also it shows??
 pls provide me o/p of this questiona nd also tell how use use variable of
 one file in other as simply writing extern in a is not accesing global a of
 other file

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] longest palindrome in a string size 2*10^4

2012-09-23 Thread SHOBHIT GUPTA
http://www.leetcode.com/2011/11/longest-palindromic-substring-part-ii.html:
linear time

On Sat, Sep 22, 2012 at 5:33 PM, Aditya Raman adityarareloa...@gmail.comwrote:

 Hello everybody,
 I need to find a way of finding the longest palindrome in a very very long
 string (n=2) . a linear time algo is expected. help me out

 --
 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/-/JdXOBU9fu34J.
 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.


-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Enter in the loop challenge

2012-09-06 Thread SHOBHIT GUPTA
also the keywords like int , long etc cannot be included in macro

On Wed, Sep 5, 2012 at 7:01 PM, Shashank Jain shashank29j...@gmail.comwrote:

 thanks that was a really nice explanation

 shashank


 On Wed, Sep 5, 2012 at 6:48 PM, Bala cmb...@gmail.com wrote:

 Source: http://gcc.gnu.org/onlinedocs/cpp/Macros.html

 You may define any valid identifier as a macro, even if it is a C
 keyword. The preprocessor does not know anything about keywords. This
 can be useful if you wish to hide a keyword such as const from an
 older compiler that does not understand it. However, the preprocessor
 operator defined (see Defined) can never be defined as a macro, and
 C++'s named operators (see C++ Named Operators) cannot be macros when
 you are compiling C++.


 Cheers,
 -Bala

 “Judge nothing, be happy.
  Forgive everything, be happier.
  Love everything, be happiest.”
 ~Sri Chinmoy


 On Wed, Sep 5, 2012 at 8:12 AM, Shashank Jain shashank29j...@gmail.com
 wrote:
  can you plz explain how it happens ...as valid macro names  must not be
 key
  words.
 
 
  On Wed, Sep 5, 2012 at 6:24 PM, Shashank Jain shashank29j...@gmail.com
 
  wrote:
 
 
  it works
  thanks for your reply
 
 
 
  On Wed, Sep 5, 2012 at 6:19 PM, Bala cmb...@gmail.com wrote:
 
  #define while(x) while(1)
 
  Cheers,
  -Bala
 
 
 
  On Wed, Sep 5, 2012 at 7:45 AM, Shashank Jain 
 shashank29j...@gmail.com
  wrote:
   Here is a question...and i am badly stuck at it
  
   how would you get into the loop
  
   int main()
   {
  
while ( 0)
{
  printf(hello);
  
}
   return 0;
   }
  
  
   You cannot change the while loop and its condition and you have to
   print
   hello
  
   --
   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 group at
   http://groups.google.com/group/algogeeks?hl=en.
 
  --
  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 group at
  http://groups.google.com/group/algogeeks?hl=en.
 
 
 
  --
  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 group at
  http://groups.google.com/group/algogeeks?hl=en.

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] JAVA PROGRAM ERROR

2012-08-22 Thread SHOBHIT GUPTA
Error : U didnt declare the variable n in stringTimes function . Just
replace x with n . U'll get the answer .

On Wed, Aug 22, 2012 at 12:41 AM, Rajesh Kumar testalgori...@gmail.comwrote:

 class StringTimes
 {
 public static void main(String args[])
 {
 String str=Hi;
 long i=2;
 String get;
 get=stringTimes(str,i);
 System.out.println(get);
 }
 public static String stringTimes(String str,long x)
 {
   int i;
  String set=str;
  for(i=0;in-1;i++)
  {
  set+=str;
  }
  return set;
 }
 }

 OUTPUT should be like:HiHi

 but it gives error plz someone help me
 --
 Regards
 Rajesh Kumar


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] direct i online test

2012-08-13 Thread SHOBHIT GUPTA
shouldn't be the sum i.e. 4 taken as 1 ?

On Mon, Aug 13, 2012 at 11:06 AM, vivek rungta vivekrungt...@gmail.comwrote:


 if sum is 4 output will be 33



 On Mon, Aug 13, 2012 at 10:29 AM, SHOBHIT GUPTA 
 shobhitgupta1...@gmail.com wrote:

 what will be the output if the sum is 4 ?

 On Sun, Aug 12, 2012 at 11:22 PM, harsha harshacoo...@gmail.com wrote:

  A smart 3 year old Sandeep knows counting. But he doesn't know how to
 read and write properly. He has learnt 1, 2 and 3 but thinks that 4 is
 another way to write 1.
 So when given any number with 1, 2, 3  4, he tries to sum up their
 digits as follows :

 213 = 2 + 1 + 3 = 6
 33 = 3 + 3 = 6
 1341 = 1 + 3 + 1 + 1 = 6
 (remember, the kid thinks that 4 = 1)

 Sandeep gets excited to discover that different numbers can all add up
 to the same sum. He now wants to know how many numbers there are whose sum
 is a number N. For N = 2, he can make 5 numbers: 11, 14, 41, 44, and 2. (He
 knows how to count up beyond five, just not how to write it)

 He needs your help for other such values of N.
 Input/Output

 You don't have to read or write anything from/to stdin and stdout
 respectively. Use the template code provided in the editor on the
 submission page, that does the IO for you.

 In the template, you have to write a function that takes N as argument
 and returns the count of numbers Sandeep can make such that the sum of
 their digits is equal to N. Since the count could be very large, return the
 result mod 17
 Function Signature:
 int dumb_sum(int N);

 The template code executes the function submitted T times with different
 arguments. Constraint

 0  T  1
 1 ≤ N ≤ 1000.
 Example*Input:*
 2
 2
 3
 *Output:*
 5
 13
 --
  Author:xyler http://www.codechef.com/users/xyler Date 
 Added:10-08-2012Time
 Limit: 10 secSource Limit: 5 BytesLanguages: C, CPP 4.3.2, JAVA

 --
 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/-/tD_1SLVj0QgJ.
 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.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] direct i online test

2012-08-12 Thread SHOBHIT GUPTA
what will be the output if the sum is 4 ?

On Sun, Aug 12, 2012 at 11:22 PM, harsha harshacoo...@gmail.com wrote:

 A smart 3 year old Sandeep knows counting. But he doesn't know how to read
 and write properly. He has learnt 1, 2 and 3 but thinks that 4 is another
 way to write 1.
 So when given any number with 1, 2, 3  4, he tries to sum up their digits
 as follows :

 213 = 2 + 1 + 3 = 6
 33 = 3 + 3 = 6
 1341 = 1 + 3 + 1 + 1 = 6
 (remember, the kid thinks that 4 = 1)

 Sandeep gets excited to discover that different numbers can all add up to
 the same sum. He now wants to know how many numbers there are whose sum is
 a number N. For N = 2, he can make 5 numbers: 11, 14, 41, 44, and 2. (He
 knows how to count up beyond five, just not how to write it)

 He needs your help for other such values of N.
 Input/Output

 You don't have to read or write anything from/to stdin and stdout
 respectively. Use the template code provided in the editor on the
 submission page, that does the IO for you.

 In the template, you have to write a function that takes N as argument and
 returns the count of numbers Sandeep can make such that the sum of their
 digits is equal to N. Since the count could be very large, return the
 result mod 17
 Function Signature:
 int dumb_sum(int N);

 The template code executes the function submitted T times with different
 arguments.Constraint

 0  T  1
 1 ≤ N ≤ 1000.
 Example*Input:*
 2
 2
 3
 *Output:*
 5
 13
 --
 Author:xyler http://www.codechef.com/users/xylerDate Added:10-08-2012Time
 Limit:10 secSource Limit:5 BytesLanguages:C, CPP 4.3.2, JAVA

 --
 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/-/tD_1SLVj0QgJ.
 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.


-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Directi Written Q 2012

2012-07-31 Thread SHOBHIT GUPTA
wat abt 32

On Mon, Jul 30, 2012 at 4:02 PM, Lucifer sourabhd2...@gmail.com wrote:

 @ ruru
 I think we can do it in log(n)..
 I am not jolting down the code but giving out the idea that would lead
 to log(n) time..

 If we write down all the nos. in the binary format one below the
 other.. we will observe the following pattern :-

 at bit index '1' the bit value toggles in group of '01'
 at bit index '2' the bit value toggles in group of '0011' ans so on..

 Hence using basic divisibility property we can calculate the no. of
 one's at every it index 'i' where 'i' ranges from 1 to log(N)..


 On 30 July, 15:25, Zyro vivkum...@gmail.com wrote:
  int func(int start,int end)
  {
 int count=0;
 for(int i=start;i=end;i++)
  {
 int tmp=i;
 while(tmp!=0)
 {
tmp=tmp(tmp-1);
count++;
 }
 }
return count;
 
  }
 
  Worst Case complexity : O((b-a)*32)
 
  Please let me know if there is another gud way to do it.. :)
 
 
 
 
 
 
 
  On Tuesday, 24 July 2012 15:09:42 UTC+5:30, ruru wrote:
 
   find no. of 1's in binary format of numbers from 1 to 100. like for
   1 to 10 answer is 17
 
  On Tuesday, 24 July 2012 15:09:42 UTC+5:30, ruru wrote:
 
   find no. of 1's in binary format of numbers from 1 to 100. like for
   1 to 10 answer is 17

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.



-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: Directi Written Q 2012

2012-07-31 Thread SHOBHIT GUPTA
sory fr prev wrng cmnt

On Mon, Jul 30, 2012 at 4:04 PM, SHOBHIT GUPTA
shobhitgupta1...@gmail.comwrote:

 wat abt 32


 On Mon, Jul 30, 2012 at 4:02 PM, Lucifer sourabhd2...@gmail.com wrote:

 @ ruru
 I think we can do it in log(n)..
 I am not jolting down the code but giving out the idea that would lead
 to log(n) time..

 If we write down all the nos. in the binary format one below the
 other.. we will observe the following pattern :-

 at bit index '1' the bit value toggles in group of '01'
 at bit index '2' the bit value toggles in group of '0011' ans so on..

 Hence using basic divisibility property we can calculate the no. of
 one's at every it index 'i' where 'i' ranges from 1 to log(N)..


 On 30 July, 15:25, Zyro vivkum...@gmail.com wrote:
  int func(int start,int end)
  {
 int count=0;
 for(int i=start;i=end;i++)
  {
 int tmp=i;
 while(tmp!=0)
 {
tmp=tmp(tmp-1);
count++;
 }
 }
return count;
 
  }
 
  Worst Case complexity : O((b-a)*32)
 
  Please let me know if there is another gud way to do it.. :)
 
 
 
 
 
 
 
  On Tuesday, 24 July 2012 15:09:42 UTC+5:30, ruru wrote:
 
   find no. of 1's in binary format of numbers from 1 to 100. like for
   1 to 10 answer is 17
 
  On Tuesday, 24 July 2012 15:09:42 UTC+5:30, ruru wrote:
 
   find no. of 1's in binary format of numbers from 1 to 100. like for
   1 to 10 answer is 17

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.




-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Re: absolute minimum difference

2012-07-28 Thread SHOBHIT GUPTA
@Arun : sort the array acc to their abs values .

On Sat, Jul 28, 2012 at 9:51 AM, Arun Kindra arunkin...@gmail.com wrote:

 @Dave Sir : Sir if u sort the array(given above) the array would be:
 -20,-8-2,4,9,10,12,14,17, and according to ur suggestion, the only ans is
 {9,10}...but one of the ans {9,-8} is also possible...as he is asking
 the difference in absolute values.

 correct me if i m wrong...

 --
 You received this message because you are subscribed to the Google Groups
 Algorithm Geeks group.
 To post to this group, send email to 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.


-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] what will be output for this program ?

2012-07-28 Thread SHOBHIT GUPTA
64 32
16 32
16 32
64 32

Wats d prob ?
On Fri, Jul 27, 2012 at 6:48 PM, Hraday Sharma hradaysha...@gmail.comwrote:

 #includestdio.h
  int main(){
 printf(%d %d\n, 321, 320);
 printf(%d %d\n, 32-1, 32-0);
 printf(%d %d\n, 321, 320);
 printf(%d %d\n, 32-1, 32-0);
 return 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/-/oJogPmV-5msJ.
 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.


-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] [Amazon]

2012-07-24 Thread SHOBHIT GUPTA
Sorry , I've tried but BS will not work here .

On Tue, Jul 24, 2012 at 9:17 PM, algo bard algo.b...@gmail.com wrote:

 @Shobhit: Can you give me a few hints on implementing a BS on the 2D?
 @neelpulse: That's what I said. A 2D array *might* be a probable
 candidate. In your example, the first 2d satisfies the criteria...so we
 check it -- Not found -- Reject -- Move on to next probable candidate.

 On Sat, Jul 21, 2012 at 5:14 PM, neelpulse(Jadavpur University) 
 neelpu...@gmail.com wrote:

 May be I am missing a few details. But Consider this 3D array:
 {
{
   {1,2},
   {7,8} // First 2D array
 },
 {
{3,4},
{9,10}
  }
 }
 If you search for 3 then your search in first step will give first 2D
 which actually does not contain 3. As per my interpretation of the problem,
 my array is holding the preconditions.

 On Friday, 20 July 2012 16:25:49 UTC+5:30, algo bard wrote:

 Compare the element with the first([0][0]) and the last
 element([n-1][n-1]) of each 2D array to pin down the 2D array it *might* be
 present in.
 After that you can follow this approach :  http://www.geeksforgeeks.org/
 **archives/11337 http://www.geeksforgeeks.org/archives/11337

 If it's not present in that 2D, move on and search for the next target
 2D.

 The Probable 2D target set will be given by :
 arr[i][0][0]=element=arr[i][**n-1][n-1].
 Reject the 2Ds which don't follow this condition.

 TC: O(n^2)

 Though, I think an O(n) approach must exist for this problem.

 On Fri, Jul 20, 2012 at 11:24 AM, Sakshi Agrawal 
 sweetsaksh...@gmail.com wrote:

 How will you search an element in sorted 3D Array ?  ( Sorted in all
 the 3 directions )

 --
 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+unsubscribe@**
 googlegroups.com algogeeks%2bunsubscr...@googlegroups.com.
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=en http://groups.google.com/group/algogeeks?hl=en.


  --
 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/-/UKYO8gE0s08J.

 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.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] [Amazon]

2012-07-20 Thread SHOBHIT GUPTA
@algo bard : Why dont you use binary search in your first step (while
comparing first and last element of 2d array)

On Fri, Jul 20, 2012 at 4:25 PM, algo bard algo.b...@gmail.com wrote:

 Compare the element with the first([0][0]) and the last
 element([n-1][n-1]) of each 2D array to pin down the 2D array it *might* be
 present in.
 After that you can follow this approach :
 http://www.geeksforgeeks.org/archives/11337

 If it's not present in that 2D, move on and search for the next target 2D.

 The Probable 2D target set will be given by :
 arr[i][0][0]=element=arr[i][n-1][n-1].
 Reject the 2Ds which don't follow this condition.

 TC: O(n^2)

 Though, I think an O(n) approach must exist for this problem.


 On Fri, Jul 20, 2012 at 11:24 AM, Sakshi Agrawal 
 sweetsaksh...@gmail.comwrote:

 How will you search an element in sorted 3D Array ?  ( Sorted in all the
 3 directions )

 --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.



Re: [algogeeks] Appropriate data structure

2012-07-15 Thread SHOBHIT GUPTA
agree with naveen

On Sun, Jul 15, 2012 at 6:24 PM, Navin Kumar algorithm.i...@gmail.comwrote:

 I think stack would solve the purpose. please comment.

 On Sun, Jul 15, 2012 at 5:42 PM, enchantress elaenjoy...@gmail.comwrote:

 It says K days if you keep heap the order of values gets disturbed. How
 are last k values accessed then?


 On Sunday, 15 July 2012 12:46:02 UTC+5:30, adarsh kumar wrote:

 Min or max heap accordingly. This will do the job in O(log n) time.

 On Sun, Jul 15, 2012 at 1:25 AM, Navin Kumar 
 algorithm.i...@gmail.comwrote:

 A set of integer values are being received (1 per day). Store these
 values and at any given time, retrieve the min and max value over the last
 k days. What data structures would you use for storing and retrieving ?

 --
 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/-/2AhV1Xn3jD8Jhttps://groups.google.com/d/msg/algogeeks/-/2AhV1Xn3jD8J
 .
 To post to this group, send email to algogeeks@googlegroups.com.
 To unsubscribe from this group, send email to algogeeks+unsubscribe@**
 googlegroups.com algogeeks%2bunsubscr...@googlegroups.com.
 For more options, visit this group at http://groups.google.com/**
 group/algogeeks?hl=en http://groups.google.com/group/algogeeks?hl=en.


  --
 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/-/peWhqjKLIH8J.

 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.


  --
 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 group at
 http://groups.google.com/group/algogeeks?hl=en.


-- 
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 group at 
http://groups.google.com/group/algogeeks?hl=en.