The problem boils down to this:
http://www.geeksforgeeks.org/archives/6463
On Tue, Aug 7, 2012 at 1:59 PM, manish patel wrote:
> This is maximum sub-array problem. Nice explaination is given in CLRS -
> "Introduction to algorithms " Pg 68, ch-4 3rd edition
>
>
> On Tue, Aug 7, 2012 at 11:00 AM,
This is maximum sub-array problem. Nice explaination is given in CLRS -
"Introduction to algorithms " Pg 68, ch-4 3rd edition
On Tue, Aug 7, 2012 at 11:00 AM, Navin Gupta wrote:
> @ashgoel :- Thanx for pointing it out, my earlier approach doesn't work.
> Please check if this works.
> We can appl
@ashgoel :- Thanx for pointing it out, my earlier approach doesn't work.
Please check if this works.
We can apply this:-
For every element, find the highest element to the right of it.
For e.g:
I/P:- 35 4015 35 10 20
Highest to Right:- 40 3535 20
the only one scenario.
> Other like random order profits and loss so need to decide min n max for a
> interval.
>
> Here is no profit
> 9 8 7 6 5 4 3 2 1 :(.
> Sent from my Windows Phone
> --
> From: Mukul Gupta
> Sent: 08/05/2012 8:47 PM
>
random order profits and loss so need to decide min n max for a
interval.
Here is no profit
9 8 7 6 5 4 3 2 1 :(.
Sent from my Windows Phone
--
From: Mukul Gupta
Sent: 08/05/2012 8:47 PM
To: algogeeks@googlegroups.com
Subject: Re: [algogeeks] DE Shaw written test
Thanks for
Thanks for pointing out the mistake.Though my code will correctly calculate
the max_profit but I must keep track of the buying_day.I have made some
modification in my code.Hope it works fine now.
int min = a[0]; // initialized to first element
int max_profit = 0; //when you buy and sell on same
@harsha : yes, the problem is if u r finding only min and max value, it
might happen that u sell the stock before buying. Ex- int a [ ] = { 5, 10,
4, 6, 7 }; the min value is 4 and max is 10 and 10 comes before 4, means u
sell the stock before buying.
and i think the sol given by mukul does the sa
This can be done in O(n) time complexity and O(1) space complexity using
dynamic programming.Consider a situation in which I have been given an
array of stock values for N days (in your case N=365) which looks like:
int a [ ] = { 5, 10, 4, 6, 7 };
Now,use two variables min (which will keep track
there is a stock company whose stock prices are known to u for next 365
days. u have to write the code on which day u should buy and sell the
stock. U cannot sell a stock until you haven't bought any stock.
my approach was to buy the stock when the stock prices are the lowest and
sell them when
hi neha how are you send me a nice mail of nature plz reply me i m online
now
--
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
algo
:) thanks for such gud words guys
On Tue, Sep 6, 2011 at 2:47 PM, sukran dhawan wrote:
> ya dont be upset if some one who is not as good as u get a job and u don
> get it ... think positively ... think that the company don deserve u and
> start working on ur weak areas
>
> On Tue, Sep 6, 2011 at
ya dont be upset if some one who is not as good as u get a job and u don get
it ... think positively ... think that the company don deserve u and start
working on ur weak areas
On Tue, Sep 6, 2011 at 2:34 PM, siddharam suresh wrote:
> my personal experience.
> guys don't regret while placements,
my personal experience.
guys don't regret while placements,
it wont bring any work-ability in the preparation.
always look for what was missing in the last interview, prepare well.
I didnt prepare because of the initial failure in the placements(ended up
where i did not planed). I wish that wont h
:D
may be u lost this to gt something better :-)
On Tue, Sep 6, 2011 at 4:32 AM, ROHIT SINGHAL wrote:
> due to this singleton class i lost 6.5 lpa opportunity :( in Hcentive noida
>
>
> On Tue, Sep 6, 2011 at 12:58 PM, rahul vatsa wrote:
>
>> there is no restriction at all, you can create n no of
due to this singleton class i lost 6.5 lpa opportunity :( in Hcentive noida
On Tue, Sep 6, 2011 at 12:58 PM, rahul vatsa wrote:
> there is no restriction at all, you can create n no of objects. A member
> function can call a private constructor any number of times.
>
> Just 1 single object is cr
there is no restriction at all, you can create n no of objects. A member
function can call a private constructor any number of times.
Just 1 single object is created bcoz this is the property of singleton
class.
A singleton class is a class which ensures the class has only one instance &
it provid
bcoz u cant keep reinitializing the same object
On 5 September 2011 22:15, Neha Singh wrote:
> Guys hv a doubt, plz clarify ..
> You mentioned that if a class has a private constructor then the object of
> that class can be created using call to a static method which internally
> calls the const
Calling the static method multiple times will return the same instance not
multiple instances, that is the essence of singleton design pattern.
Example: http://www.docjar.com/html/api/java/lang/Runtime.java.html
On Mon, Sep 5, 2011 at 10:45 PM, ravindra patel wrote:
> it usually works like this
it usually works like this -
public class Test1
{
private static Test1 obj; // Static member hence singleton
private Test1() // To prevent the Compiler from creating default
constructor
{
// Do whatever initialization required
}
public static Test1 getIn
Guys hv a doubt, plz clarify ..
You mentioned that if a class has a private constructor then the object of
that class can be created using call to a static method which internally
calls the constructor and returns its reference. I can't understand why only
1 object can be created as mentioned by yo
Thnks everybody ..
--
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
hey guys fro where i can find open source project to workon??
On Mon, Sep 5, 2011 at 9:44 PM, sukran dhawan wrote:
> for singletion class
>
>
> On Mon, Sep 5, 2011 at 9:42 PM, Sanjay Rajpal wrote:
>
>> I think when we have to create a singleton class, we can use private
>> constructor. Objects o
for singletion class
On Mon, Sep 5, 2011 at 9:42 PM, Sanjay Rajpal wrote:
> I think when we have to create a singleton class, we can use private
> constructor. Objects of such classes can be constructed using static
> functions that can be accessed using class name and scope resolution
> operato
I think when we have to create a singleton class, we can use private
constructor. Objects of such classes can be constructed using static
functions that can be accessed using class name and scope resolution
operators. This is useful because user can create only one object of that
class, which is so
When do u hv a private constructor for a class ???
How to create an object of such a class ??
What's its utility ??
Anyone plz explain asap??
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@goo
hey but 935*2+69 = 1939 and when this is divided by 38 remainder iscoming to
be 1..i guess so.. is it ryt?
On Wed, Aug 17, 2011 at 9:55 PM, aditya kumar
wrote:
> i guess if the option is provided it would have been an appropiate question
> .
>
>
> On Wed, Aug 17, 2011 at 6:02 PM, Rohit Srivastava
i guess if the option is provided it would have been an appropiate question
.
On Wed, Aug 17, 2011 at 6:02 PM, Rohit Srivastava wrote:
> +1 to nitin
>
>
> On Wed, Aug 17, 2011 at 6:02 PM, Romil ... wrote:
>
>> People this is not the way to approach this one. This question seems to be
>> unfai
+1 to nitin
On Wed, Aug 17, 2011 at 6:02 PM, Romil ... wrote:
> People this is not the way to approach this one. This question seems to be
> unfair. Take the number to be 1939 which also leaves 69 as the remainder
> when divided by 935 but when it is divided by 38, the remainder is only 1.
>
People this is not the way to approach this one. This question seems to be
unfair. Take the number to be 1939 which also leaves 69 as the remainder
when divided by 935 but when it is divided by 38, the remainder is only 1.
There is definitely some mistake. Also there doesn't seem to be a
mathematic
N = 935*q + 69
N%38 = 31, 16, 1, 24, 9, 32, 17, 2 for { q = 0,1,2,3,4,5,6,7. }
On Wed, Aug 17, 2011 at 5:54 PM, aditya kumar
wrote:
> @priya . i have shown you my method . write your method and we shall
> discuss it .
>
>
> On Wed, Aug 17, 2011 at 5:52 PM, sukran dhawan wrote:
>
>>
>>
>>
i solved it the same way you solved it. Took the same exmpl too :)
--
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+unsub
@priya . i have shown you my method . write your method and we shall discuss
it .
On Wed, Aug 17, 2011 at 5:52 PM, sukran dhawan wrote:
>
>
> On Wed, Aug 17, 2011 at 5:39 PM, priya ramesh <
> love.for.programm...@gmail.com> wrote:
>
>> if a number is divided by 935 remainder is 69. if same no. is
On Wed, Aug 17, 2011 at 5:39 PM, priya ramesh <
love.for.programm...@gmail.com> wrote:
> if a number is divided by 935 remainder is 69. if same no. is divided by
> 38, what will be the remainder?
>
> -- answer is 16.t
> You received this message because you are subscribed to the Google Groups
> "A
i got the same answer. the ans is supposed to be 29
--
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...@googlegr
16 is the answer ???
On Wed, Aug 17, 2011 at 5:39 PM, priya ramesh <
love.for.programm...@gmail.com> wrote:
> if a number is divided by 935 remainder is 69. if same no. is divided by
> 38, what will be the remainder?
>
> --
> You received this message because you are subscribed to the Google Grou
let the number be 935+69 = 1004
(bcoz divide 1004%935 = 69 )
now 1004 % 38 = 16 ANS
On Wed, Aug 17, 2011 at 5:39 PM, priya ramesh <
love.for.programm...@gmail.com> wrote:
> if a number is divided by 935 remainder is 69. if same no. is divided by
> 38, what will be the remainder?
>
> --
> You rece
if a number is divided by 935 remainder is 69. if same no. is divided by 38,
what will be the remainder?
--
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
can someone please suggest sample ques for de shaw ?? some lnk would help
--
thanks
--mac
--
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
came across this on other forum..
http://forums.sureshkumar.net/de-shaw-placement-papers/17885-deshaw-technical-questions.html
On 13 August 2011 23:32, sukran dhawan wrote:
> MVIT ?
>
> On Sat, Aug 13, 2011 at 9:02 PM, Dipankar Patro wrote:
>
>> Which college?
>>
>>
>> On 13 August 2011 20:52, r
MVIT ?
On Sat, Aug 13, 2011 at 9:02 PM, Dipankar Patro wrote:
> Which college?
>
>
> On 13 August 2011 20:52, ravinder s wrote:
>
>>
>>
>> hi can anyone tell me the pattern of de shaw ?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" g
MVIT
On Sat, Aug 13, 2011 at 9:02 PM, Dipankar Patro wrote:
> Which college?
>
>
> On 13 August 2011 20:52, ravinder s wrote:
>
>>
>>
>> hi can anyone tell me the pattern of de shaw ?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Algorithm Geeks" gro
Which college?
On 13 August 2011 20:52, ravinder s wrote:
>
>
> hi can anyone tell me the pattern of de shaw ?
>
> --
> 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 un
hi can anyone tell me the pattern of de shaw ?
--
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.
hi does any body know what kind of question is asked in DE SHAW first
round??please reply by tomorrow.
--
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 fro
In the question it is specified that the data structure should have a worst
case time complexity of O(N)
--
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
using array, we can do in O(logn) always as it is ordered. If all values
hash to same bucket in case of hashtable, it would be O(n) worse case
On Thu, Jul 28, 2011 at 12:03 AM, rajeev bharshetty wrote:
> Hash Table with Bucket , made of linked list .
>
> At most if all n values hash to same bucke
d) Hast table with bucket, made up of linked list, where linked list
have no ordering.
--
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
I think Ordered array Search time = O(logn) whereas for bucket
complexity=O(sqrt(n)) as it is unordered.
--
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
Hash Table with Bucket , made of linked list .
At most if all n values hash to same bucket then at worst case we must
traverse n linked list nodes to find the element.
Hope it is clear
On Wed, Jul 27, 2011 at 11:59 PM, Reynald wrote:
> Which of the following data structure do better job (has l
Which of the following data structure do better job (has lesser time
complexity) at searching elements that has a worst-case time
complexity of O(n)? Do not account for the cost of building the Data
structure in searching cost.
a) Linked list with element sorted by value
b) Binary tree with no orde
Nice Solution!
--
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/-/PGCJcmtuYqEJ.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe
There are only 2 types of heaps in this problem:
1. Optional heaps -> have > 1 coins
2. Non-optional heaps -> have = 1 coins
Start from the rightmost heap.
This is base case - whoever gets this heap surely wins.
Look at the heaps before it.
If it is a non-optional heap (1 element only), then the
yep true.
The difficult part is trying to find when Player 1 can win with heaps of
size 1.
Thanks,
Immanuel
On Wed, Jun 15, 2011 at 6:59 PM, sunny agrawal wrote:
> i think solution depends on no of heaps having single coin
> if there are even number of such heaps player 1 will win
> if there ar
no that also wont work
n=2
3,1
On Wed, Jun 15, 2011 at 6:59 PM, sunny agrawal wrote:
> i think solution depends on no of heaps having single coin
> if there are even number of such heaps player 1 will win
> if there are odd number of such heaps player 2 will win
>
>
> On Wed, Jun 15, 2011 at 6:49
i think solution depends on no of heaps having single coin
if there are even number of such heaps player 1 will win
if there are odd number of such heaps player 2 will win
On Wed, Jun 15, 2011 at 6:49 PM, Nitish Garg wrote:
> Player 1 can still win in this case: Player 1 can take 1 from the firs
Player 1 can still win in this case: Player 1 can take 1 from the first heap
forcing Player 2 to take the remaining 1. Then Player 1 can take the 2 coins
from the second heap and win.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To view
@Nitish
n=2
heap 1 = 2
heap 2 = 3
Xor = 1
still player one can win :)
On Wed, Jun 15, 2011 at 6:49 PM, sunny agrawal wrote:
> @immanuel
> ohh, i read the Question wrong. :(
> i was thinking player1 is starting from least numbered heap and player 2
> from highest no heap
>
>
>
> On Wed, Jun 15,
@Nitish,
I think it fails for this condition
4 heaps with 1,2,1,2
Player 1 starts first with picking 1 coin from heap 1
Player 2 picks 2 coins from heap 2
Player 1 picks 1 coin from heap 3
Player 2 picks 2 coins from heap 4.
Player 2 wins but XOR of the number of coins in each heap is 0(if that
@immanuel
ohh, i read the Question wrong. :(
i was thinking player1 is starting from least numbered heap and player 2
from highest no heap
On Wed, Jun 15, 2011 at 6:36 PM, immanuel kingston <
kingston.imman...@gmail.com> wrote:
> Player 1 will take 1 coin from heap 1
> Player 2 has to take th
I think that when the XOR of all the coins is zero Player 1 can always win.
--
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/-/EQtViYQFACMJ.
To post to this gr
Player 1 will take 1 coin from heap 1
Player 2 has to take the other coin from heap1.
Player 1 will take both the coins in heap 2.
Thanks,
Immanuel
On Wed, Jun 15, 2011 at 6:33 PM, sunny agrawal wrote:
> check out this case
> n = 2
> both heaps having 2 coins
> player 2 will win i think
>
>
>
check out this case
n = 2
both heaps having 2 coins
player 2 will win i think
On Wed, Jun 15, 2011 at 6:26 PM, immanuel kingston <
kingston.imman...@gmail.com> wrote:
> Yes. I am wrong. As per the example, Player 2 will win if he plays
> efficiently.
>
> Let me put my solution this way,
>
> If al
Yes. I am wrong. As per the example, Player 2 will win if he plays
efficiently.
Let me put my solution this way,
If all the the heaps are of size > 1 the Player 1 can win always.
Thanks,
Immanuel
On Wed, Jun 15, 2011 at 5:36 PM, sunny agrawal wrote:
> consider the case.
> n = 2;
> heap 1 -> no
consider the case.
n = 2;
heap 1 -> no of coins 1
heap 2 -> no of coins 2
On Wed, Jun 15, 2011 at 5:34 PM, sunny agrawal wrote:
> i think u r wrong
> what if heap size -1 is 0
> i think one should pick atleast one coin else game will draw
>
>
> On Wed, Jun 15, 2011 at 5:17 PM, immanuel kingst
i think u r wrong
what if heap size -1 is 0
i think one should pick atleast one coin else game will draw
On Wed, Jun 15, 2011 at 5:17 PM, immanuel kingston <
kingston.imman...@gmail.com> wrote:
> First Player can always win.
>
> For each heap
>Pick heap-size - 1 coins if this is not the n
First Player can always win.
For each heap
Pick heap-size - 1 coins if this is not the n-1th heap
Pick all coins from the heap if this the n-1th heap.
Please correct me if i am wrong.
Thanks,
Immanuel
On Wed, Jun 15, 2011 at 3:13 PM, Piyush Sinha wrote:
> *There are n heaps of coin(numbe
*There are n heaps of coin(numbered from 0 to n-1) with atleast 1 coin in
each heap. There are 2 players. First player can pick any no. of coins from
the least numbered heap, then the second player can pick any no. of coins
from the least numbered heap. Unless it is emptied, the player cant move on
67 matches
Mail list logo