Thank u, I got it.
On Thu, Dec 1, 2011 at 1:15 PM, Sri Harsha wrote:
> 10 dequeue operations and 9 enqueue operations. the extra dequeue is to
> pop. the 9 dequeues are to remove from this queue and 9 enqueues to insert
> into the 2nd queue
>
> On Thu, Dec 1, 2011 at 11:51 AM, Vijay Khandar
10 dequeue operations and 9 enqueue operations. the extra dequeue is to
pop. the 9 dequeues are to remove from this queue and 9 enqueues to insert
into the 2nd queue
On Thu, Dec 1, 2011 at 11:51 AM, Vijay Khandar wrote:
> A stack is implemented with two queues then what are the minimum
> enqueue
@atul.. thanks for pointing out.. i m doing a small mistake in
calculating closest element found... and i have rectified it below...
Also i have missed a corner case in the above solution hence i m
putting it down here...
3a) Corner case: Do modified binary search for closest element smaller
than
A stack is implemented with two queues then what are the minimum
enqueue and dequeue operations needed to perform for pop
operation,where '10' elements are already in the first queue?
please anyone provide soln with explation.
--
You received this message because you are subscribed to t
@sourabh :
*Cumulative SUM*
*i*
2
0
3
1
6
2
10
3
15
4
above will the array B[][] formed for array A[]={ 2,1,3,4,5 }
let X=12;
12 - 2 = 10 , closest element found = 10 , *closest to X = 2 + 10 =12*
,*i = 0 , j = 3
* // this is the answer , so i am calculating other
max nu
we can also do it by making next_ptr of head = 0 XOR address of last node.
for both this and above method we must save the address of last node in
temp while creating a XOR link list.
On Thu, Dec 1, 2011 at 9:21 AM, atul anand wrote:
> well to make it work in O(1) , i guess just make head=last
well to make it work in O(1) , i guess just make head=last node.
now just by XORing next ptr of current element with the previous element ,
we will get second last node similarly keep traversing .
On Thu, Dec 1, 2011 at 7:02 AM, Rajeev Kumar wrote:
>
>
> --
> Thank You
> Rajeev Kumar
>
> --
--
Thank You
Rajeev 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 option
Find out the smallest segment in a document containing all the given
words.
Desired Complexity is O nlogK ..n is the total no of words in the
document and k is the number of input words
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post
I am rewriting the algo here in much more readable form :
Given array of integers A,
1) Create an 2-d array B[n][2] of size n*2 such that
a) B[i][0] = sum of all elements from A[0] to A[i],
b) B[i][1] = i
2) Sort array B based on B[i][0] i.e. sort array B[][0] and
correspondingly rearran
First i would like to rectify a editing mistake that is as foolws :
Say the found index after binary search is j ( which is > i)..
Now if B[i][1] < B[j][1] then keep track of the max no. closest to X
( that is B[i][0] + B[j][0])... // earlier the last text was B[i][1] +
B[j][1]
Now to clarify your
We can do it by hashing. hash the 2-d array and then search for 1 d array
in the hash table.
--
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/-/7PE1mqG4RRgJ.
@sourabh : please let me know where i am making mistake in understanding
your algo:-
considering your 1st algo:-
1) Given array of integers A[n], = {2,1,3,4,5}
2) create an array B[n] such that B[i] = sum of all elements from A[1]
to A[i], // i guess it should be A[0] to A[i]
Array B formed :-
WELL PLACED BALLS
There are W identical white balls, B identical black balls and C
containers. We need to distribute all the balls into some of the
containers. A selection is done by randomly picking a container followed by
randomly picking a ball in it. We need to maximise the probability of
picki
Here is the python code for the similar problem:
http://codercharts.com/puzzle/its-raining-anagrams
The first command line parameter is dictionary file, the second is the
file with checked words.
The idea is to preprocess the dictionary in few steps:
1. calc the set of lengths of the checked words.
Given array of integers A, create an 2-d array B of size n*2 such
that B[i][0] = sum of all elements from A[0] to A[i], B[i][1] = i;Now
sort array B based on B[i][0]..
Now for each element B[i][0] ( till its smaller that equal to X), do a
(modified) binary search for the closest value smaller th
Given array of integers A[n],
create an array B[n] such that B[i] = sum of all elements from A[1]
to A[i],
Now sort array B, and for each element B[i] ( smaller that equal to
X), do a (modified) binary search for the closest value smaller than
equal to (X - B[i]) in array B[i+1... n]
Keep track
One approach could be using the file.
Say x = 50 %, so every alternate run, the output should be true.
1. First run, store 0.5 in the file
2. Second run, add 0.5 to the previous value
3. Check if the sum is 1.d where 0 <= d < 1, return true and store 0.d in
the file
We can extend the same logic f
18 matches
Mail list logo