@Nishan :
For the given example, the number of elements which are not in order may be
less ..can u prove this ?
And also, how can u place an incorrect positioned number at correct
position --- takes O(n) for each number
On Sun, May 26, 2013 at 8:55 PM, Ankit Agarwal
@Nishant :
Don's algo :
first he is counting #of bits of all numbers from 0 to 65536 and
maintaining in an array bitCount.
Converted the input array into of type short. short range is 0 to 65536.
for the given input, he is getting the number of bits set using bitCount[]
.. its like
http://stackoverflow.com/questions/14686745/guards-and-demand/14687760#14687760
On Sun, May 5, 2013 at 9:44 AM, rohit jangid rohit.nsi...@gmail.com wrote:
a very standard dp problem . try to formulate recurrence relation . it has
been mentioned a couple of times on stackoverflow as well .
On
Minimum of coins to sum s
--
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.
Create a BST from given list such that team that has won should be
right child of node and and teams that has lost should be left child
of node and then traverse the tree in reverse in order.
Karan
On Thu, May 23, 2013 at 10:58 PM, bharat b bagana.bharatku...@gmail.com wrote:
@Don : you are
It' similar to implement min in O(1) in stack.
http://stackoverflow.com/questions/685060/design-a-stack-such-that-getminimum-should-be-o1
suppose you have implemented stack through linked list.
you can maintain another stack in parallel (say midstack)where you
keep the pointer of middle element
*Hello*
*Have you ever thought of you as a Computer Scientist contributing to
flourish music and get benefited? And how if my second conjecture is that a
person who knows dance can know programming better? Or to make the two
together, “Computing could be taught and learned by using Music and
guys ..i got solution here
http://www.geeksforgeeks.org/program-to-count-number-of-set-bits-in-an-big-array/
plz tell how its complexity is logn.
On Fri, May 17, 2013 at 6:55 PM, Don dondod...@gmail.com wrote:
Counting the set bits in one integer is not the problem which was
asked.
However,
Rope Data Structure is best suited for text editors.
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 because you are subscribed to the
Hi Nishant
As per the question, (priority queue) PQ is used to implement stack. With
PQ, you cannot do push and pop both in O(1). If you use heap tree(max heap
assuming you increase priority for upcoming pushed objects or min-heap
otherwise) for PQ, it will take O(log n) for each operation
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
--
following is code from geeks for geeks.
Please tell how the complexity of this in n*n!
n*n! times loop will be executed and then wat about the statements in
loop??
reference:-
http://www.geeksforgeeks.org/lexicographic-permutations-of-string/(second
method)
void reverse(char str[], int l, int
and how this is working
void init()
{
bitCount[0] = 0;
for(int i = 1; i 65536; ++i) bitCount[i] = bitCount[i/2] + (i1);
}
it is working fine..but plz tell the logic behind this
On Thu, May 23, 2013 at 11:12 AM, rahul sharma rahul23111...@gmail.comwrote:
@don...i got it...its complexity is
@pramidathat can be done in 0(n)..lets say int takes 4 bytes
i will make and array of first 256 numbers ...
while finding for inte i will take a char pointer pointing to first byte
and then using array of 256 int i will count in that byte and increent
array and count in it.and so
then solution i posted aboive is correct in that case???plz comment
On Fri, May 17, 2013 at 9:49 AM, avinesh saini avinesh.sa...@gmail.comwrote:
If one node is parent of other then Parent Node is lowest common ancestor.
Source- http://en.wikipedia.org/wiki/Lowest_common_ancestor (just read
static Node LCA(Node root, int a, int b) {
if (root == null)
return null;
if (root.getData() == a || root.getData() == b)
return root;
Node root1 = LCA(root.getLeft(), a, b);
Node root2 = LCA(root.getRight(), a, b);
if (root1 !=
@Prateek Jain : Middle element is nothing but a median ( i.e. middle
element in sorted state)
Soluton
1. Maintain a sorted stack using an extra stack , pop half of the elements
or get the middle and if it's implemented using arrays fetch middle index
value (top/2)
T(N)= O(n^2) to maintain a
You can use this logic to find number of bits set :-
int count = 0;
foreach(int x in array){
if(x 0)
count--; //for the sign bit will be counted below.
while(x){
x = x-1;
count++;
}
}
Thanks
Monish
On Sunday, May 12, 2013 1:05:31 AM UTC+5:30, rahul sharma wrote:
I was
Can you write the constraints for this problem?
thanks.
Adolfo
2013/5/18 rahul sharma rahul23111...@gmail.com
Minimum of coins to sum s
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To unsubscribe from this group and stop receiving
Hello,
I have 2 months holidays and right after that my placement starts. I have
good foundations in C,Java, Data structures, Networks, Operating systems
and Algorithms.
Can anybody tell exactly what and how i should prepare to get placed in
companies like Microsoft, Adobe, etc. How explain
@don...i got it...its complexity is logn..how?
On Thu, May 23, 2013 at 11:10 AM, rahul sharma rahul23111...@gmail.comwrote:
@don..you are counting in an integer only...correct if wrng?
On Wed, May 22, 2013 at 7:28 PM, Don dondod...@gmail.com wrote:
My program works with any numbers.
Don
Hi Don,
instead of searching 1 at all places we can use this :
while(n!=0){
count++;
n = n n-1;
}
On Fri, May 17, 2013 at 6:55 PM, Don dondod...@gmail.com wrote:
Counting the set bits in one integer is not the problem which was
asked.
However, I think that something like this is both
We could also use a queue.
1. Put the first element in the stack
2. load the next element in a queue
3. Continue to load into queue until front of queue is no longer the
midpoint
4. dequeue and place into stack
5. Repeat from 2.
Pop is now O(n) because we would need to dequeue into the stack and
You could also use Fly Weight pattern to implement this.
http://en.wikipedia.org/wiki/Flyweight_pattern
On Saturday, May 25, 2013 10:24:09 PM UTC+5:30, Nishant Pandey wrote:
In one of the interview it was asked, can some one suggest good DS for
this.
Thanks
--
You received this message
Since we need to divide so the quotient should be at least 1, and we need
greatest remainder, so we need the least no. which will give the quotient 1
upon dividing and that would be the no. you described.
Also you would have noted the greatest remainder would be floor(n/2)-1 .
On Thursday, 16
@nishant: I think this won't work in all the cases as you said in a
statement: one or two element won't be at correct positions.. there
might be more in other cases unless you prove it somehow. what if
array is too large and there are too many elements not at correct
position after second pass.
@don..you are counting in an integer only...correct if wrng?
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
Generate all possible combinations (of r elements) inside an array of size
N
E.g. arr [] = {2,8,14} All possible combinations of r=2 will be {2,8},
{8,14}, {14,2}
Asked in adobe
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To unsubscribe
28 matches
Mail list logo