@Snehal...wat ligerdave says is have ptr1 for list1
and ptr2 for list2.
if(ptr1->data==ptr2->data)increment both ptr1 and ptr2
else reset ptr2 to the head of list2 , increment ptr1
ptr2 position gives from where we need to concatenate.
On Sat, Oct 9, 2010 at 12:21 AM, ashita dadlani wrote:
> I
@nishaanth
hashing=O(n^2)? what kinda of hashing are we talking about?
array w/ range of the numbers? you meant smallest and the biggest?
so you have to scan through the given numbers first to find the range.
if you scanned, why not find the duplication in the first place?
okay, lets say you are
@Mukesh what's not known? in the problem, it stated "an array of
positive numbers"
On Oct 6, 11:47 am, Mukesh Gupta wrote:
> @Ankit: Insertion in hashmap in O(n) in worst case. As long as range of the
> numbers is not known we cannot predict whether the algo will run in linear
> time.
> Any other
like i said before, draw a table w/ x=a and y=b
come out w/ the matrix and you would see a patten
30 29 4 3 2 1
30 60 59 34 33 32 31
29 59 58 33 32 31 30
434 338 7 6 5
333 327 6 5 4
232 316 5 4 3
131 30
ya...finding the longest subsequence is the simplest method...and its
nlogn..
It works...it similar to box stacking problem
On Fri, Oct 1, 2010 at 6:00 AM, adit.sh...@gmail.com
wrote:
> The problem here is more about finding the most optimal solution and not
> just solution.
> Rgds
> Adi
> -
thanks for a detailed approach to the solution. :)
-
Harshal
--
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..
Keep priority queue of pairs - sum and respective indices in the
arrays.
Start from pair (a[0] + b[0], (0, 0)).
while (queue is not empty && n > 0) {
retrieve largest sum from the queue, (sum, (i, j))
add sum to the result array
--n;
add pairs (a[i + 1] + b[j], (i + 1, j)) and (a[i] + b[j
Suppose you have a stack data structure which has additional
operation findMin() - returns smallest element on the stack.
This can be easily updated in O(1) while pushing new element onto the
stack.
It is known that queue DS can be simulated by using two stacks (here
we use stacks which have findM
@Dave
input: k=3
AB
16
37
69
output should be (1,1,7), (1,2,8), (2,1,9)
im getting output form above code
(1,1,7)
(2,1,9)
(3,1,12)
Dave i am still learning algorithms .. so if i am wr
Hi Harshal,
The question is a bit unclear, especially given the *win and *def* pattern.
Does it mean anything before "win" is acceptable or anything before and
after "def" is acceptable? or is it like 'a' repeated any number of times
followed by 'b' repeated any number of times... in a*b*cd*?
I am
@snehal...a simple way to do it is..
create an array of lets say 1000...
fill in 1000* p elements with 0 and the rem with 1
now use rand() and generate the index..and return arr[index]
On Fri, Oct 8, 2010 at 8:49 PM, Dave wrote:
> @Snehal: If p has a finite binary representation, of say n bit
@Coolfrog$:
1. No. It should be O(n + k log k) because finding the kth smallest
element of an array of size n is O(n), using the Median of Medians
algorithm; see
http://en.wikipedia.org/wiki/Median_algorithm#Linear_general_selection_algorithm_-_Median_of_Medians_algorithm.
2. Assuming that the e
Given a text file, implement a solution to find out if a pattern
similar to wild cards can be detected.
for example find if a*b*cd*, or *win or *def* exists in the text.
how to take care of wild cards?
--
Harshal Choudhary
--
You received this message because you are subscribed to the Google G
@Dave
1. should it not be O(k + klogk) ??
2. but u are not considering all the possible values... let k =3
like i. a1+b1
ii. min( a1+b2, a2+b1) upto these fine one of them will be
chosen ...either ia or ib will increase.
iii. but know we have to take remaining
@nishaanth: wat if the left child of the right node has a negative value
On Thu, Oct 14, 2010 at 11:12 AM, nishaanth wrote:
>
>
>> Just see the value of the node at every point, if it is greater than zero
> dont recurse the right sub-tree, as simple as it is.print the node u
> inspected if it is
15 matches
Mail list logo