nos in character array so only characters will be printed not nos
On Sat, Aug 11, 2012 at 2:18 AM, yq Zhang zhangyunq...@gmail.com wrote:
@shiv, your code is correct go compute the base 26 number. However, this
question is not base 26 number obviously.
On Wed, Aug 8, 2012 at 4:46 AM, shiv
def long_continuous_seq(A):
ls = {}
result = (0,0)
for x in A:
if not x in ls:
left = ls[x - 1] if (x - 1) in ls else 0
right = ls[x + 1] if (x + 1) in ls else 0
if left + right + 1 result[1] - result[0]:
result = (x - left,
@shiv, your code is correct go compute the base 26 number. However, this
question is not base 26 number obviously.
On Wed, Aug 8, 2012 at 4:46 AM, shiv narayan narayan.shiv...@gmail.comwrote:
this is similar to conversion of no in base 26.( where digits are
a,b,c,d...z) just think it like
@ankush, there can be multiple probable 2D array according to your
definition.
On Wed, Jul 25, 2012 at 7:01 AM, ankush sharma anks...@gmail.com wrote:
Hi,
I think the following approach will work.
1. As the array is sorted in all three directions, assume the 3D array to
be a stack of
Vikas,
The cost of removing elements from the matrix is O(N) it self. So by
removing N^2/2 elements, the complexity of your algo should be N^3. However
there are well-known algo for median in O(N) time in this case O(N^2)
*because there are N^2 elements.
On Tue, Nov 8, 2011 at 6:58 AM, vikas
Given the SSN number is 9 digit number, the total space of possible numbers
are 1000million. So I think Dave's solution works.
On Sat, Oct 29, 2011 at 8:47 AM, bharat b bagana.bharatku...@gmail.comwrote:
@Dave
Your solution works if the total no.of records(ssn numbers) is 1000
million.
But
You should use a doubly linked list instead of any sort of array. All the
operation on the data structure you need are goto next/prev and insert
front/end.
Yunqiao
On Wed, Oct 19, 2011 at 6:40 AM, monish001 monish.gup...@gmail.com wrote:
I think it might done using function of following
@above, if initial position=final position or the final position was
empty,then choose the next element(element next to the initial position) as
current element
How do you guarantee when you move to the next element, the next element is
not already processed? Otherwise, you will double process on
but the tree can be created from a preorder walk is more than 1 right? so
the question only ask for 1?
On Feb 6, 2011 7:31 AM, jalaj jaiswal jalaj.jaiswa...@gmail.com wrote:
My solution in more detail (in words ):-
start from the end if you get an L
make a node with data L and push its pointer
can you prove it?
On Jan 29, 2011 6:38 PM, Wei.QI qiw...@gmail.com wrote:
Starting with any pump A, try to finish the circle, if at pump B that can
not reach pump B+1, it means all pumps from A to B can not finish the circle
(it will go broke at pump B), then just start with B+1. After go
The reason is simple. The same thing happen in other language such as JAVA.
You can convert Derived class to Base class but you can't convert Derived[]
to Base[]. The reason is, if your Base class has two derived classes D1, D2.
They can exist in Base[] because D1, D2 are valid Base instances.
@Dave, your algorithm is a dijkstra cycle finding algo. It requires the
function to have only ONE SINGLE cycle in the transition function. However,
the transition function for the array could have several cycles. How could
you find the duplicate? Can you elaborate more on your solution? Maybe I
Then it is O(n) worst case. While juver's algo is amortized constant time in
worst case.
On Jan 9, 2011 10:26 PM, SVIX saivivekh.swaminat...@gmail.com wrote:
The only operation for which this solution doesn't have constant time
(variable based on number of items in the list) is for 'delete' and
When you push into stack2, you have to recompute the min value. So after you
push into stack2, it will be:
(6,6),(3,3),(4,3),(2,2)
On Thu, Jan 6, 2011 at 6:34 PM, sourav souravs...@gmail.com wrote:
@Juvier, @yq Zhang
In your approach, when you are asked pop_front() you keep popping from
one
in bottom right quadrant
if xA[n/2][n/2] search in other 3 quadrants
On Sat, Dec 25, 2010 at 8:25 AM, yq Zhang zhangyunq...@gmail.com
wrote:
Suppose you have a matrix n*m. each column and row of the matrix is
already sorted. For example:
1,2,3
2,3,4
4,5,6
All 3 rows and 3 columns of above
That's a big save of space!
On Jan 5, 2011 9:03 AM, juver++ avpostni...@gmail.com wrote:
Good point. Right.
But we can avoid first stack of such structure, having separate variable
(Minimum) for this.
--
You received this message because you are subscribed to the Google Groups
Algorithm
XOR is associative and commutative. So it's similar as + operator. First
turn the array into a n*1 vector. Each round of the operation could be
interpreted as a transition matrix A*vector.
For example, suppose you have a 4 elements array (a,b,c,d )intially, then
one round of operation could be
keep min for stack is easy. just use another stack to keep the min for each
top.
Sent from Nexus one
On Jan 2, 2011 11:43 AM, Anuj Kumar anuj.bhambh...@gmail.com wrote:
@juver++ how will implwment find_min() function?
On Sun, Jan 2, 2011 at 2:33 PM, juver++ avpostni...@gmail.com wrote:
I think the original question says Path can go from left subtree tree ,
include root and go to right tree as well. This should mean the path must
include the root.
On Tue, Dec 28, 2010 at 4:52 AM, shanushaan er.srivastavaro...@gmail.comwrote:
Not clear what path you are referring to.
)
2)Ask from it's right or down element to be present at this new blank
position (Just like the heap sorting). keep on doing step 2 unless the blank
reaches the n*m position.
Again repeat the step 1 and 2 unless thr is no element left in matrix.
On Sat, Dec 25, 2010 at 9:14 AM, yq Zhang
How to solve the second question? it is different from the other question
posted where it requres only SQUARE sub matrix.
Sent from Nexus one
On Dec 25, 2010 11:00 AM, juver++ avpostni...@gmail.com wrote:
Try to search the answer before sumbitting the question here.
--
You received this
Suppose you have a matrix n*m. each column and row of the matrix is
already sorted. For example:
1,2,3
2,3,4
4,5,6
All 3 rows and 3 columns of above matrix are sorted. How to find a
specific number in the matrix?
The trivial O(nlogm) solution is to use binary search for all rows. I
am looking
, u go
down to 4 , then 5 4 so go down , u reach 6 . now 5 6 so u will need to go
left .. till u find 5 or less than 5
hope this helps
regards
--mac
On Sat, Dec 25, 2010 at 8:25 AM, yq Zhang zhangyunq...@gmail.com wrote:
Suppose you have a matrix n*m. each column and row of the matrix
@bhupendra
Nice solution!
Yq
On Wed, Dec 22, 2010 at 11:29 AM, bhupendra dubey
bhupendra@gmail.comwrote:
@juver:thanx for making me work... please notice this
this also uses the sorted property of the array
i=0,j=1;
while((i!=n-1) or j!=n)
{
/*compare difference of a[j] and a[i]*/
since you know the size, you know exactly the path to the new node.
Sent from Nexus one
On Dec 21, 2010 11:10 PM, mo...@ismu mohan...@gmail.com wrote:
it takes O(n) and also O(n)extra space(queue)
On Wed, Dec 22, 2010 at 12:37 PM, Saurabh Koar saurabhkoar...@gmail.com
wrote:
Find the first
@davesaura, i dont understand what did you mean.
Sent from Nexus one
On Dec 20, 2010 6:13 AM, Saurabh Koar saurabhkoar...@gmail.com wrote:
@Dave : Ya I understand.Thank u.
@yq: Sorry!! :(
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To
Are A, B, C sorted? If so, I believe there is a O(n1+n2+n3) solution for
this question.
Thanks
On Sun, Dec 19, 2010 at 9:57 AM, Saurabh Koar saurabhkoar...@gmail.comwrote:
You are given 3 integer arrays A, B and C of length n1, n2 and n3
respectively. All arrays are sorted. We define triplet
Koar saurabhkoar...@gmail.comwrote:
@yq: Plz explain your algorithm.
On 12/20/10, yq Zhang zhangyunq...@gmail.com wrote:
Are A, B, C sorted? If so, I believe there is a O(n1+n2+n3) solution for
this question.
Thanks
On Sun, Dec 19, 2010 at 9:57 AM, Saurabh Koar
saurabhkoar
ok. Suppose you have 3 pointers i, j, k point to the element in A, B, C
respectively. Initialize i = j =k = 0.
for each step, you will compare A[i], B[j], C[k].
if A[i] is the smallest, i++
if B[j] is the smallest, j++
if C[k] is the smallest, k++
(this assumes numbers in A,B,C are unique, you
Learning new algorithms
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options,
Learning new algorithms
--
You received this message because you are subscribed to the Google Groups
Algorithm Geeks group.
To post to this group, send email to algoge...@googlegroups.com.
To unsubscribe from this group, send email to
algogeeks+unsubscr...@googlegroups.com.
For more options,
31 matches
Mail list logo