@ashish : couldnt get u.. can u give an example??
On Tue, May 22, 2012 at 5:45 PM, Prem Krishna Chettri hprem...@gmail.comwrote:
What I Could possibly think of is
For each string S1 that is an anagram of some string S, use Map and Store
the Key Value as (S1,S). Now there is a trick here abt
Write a method to sort an array of strings so that all the anagrams are
next to each other.
What i could think of is preparing a multi linked list( multimap) whereby
the key for each string is the sorted representation of the string(eg if
string is gac, its sorted representation is acg). Walk of
What I Could possibly think of is
For each string S1 that is an anagram of some string S, use Map and Store
the Key Value as (S1,S). Now there is a trick here abt how to reduce Time
Complexity here...
Now its easy to put all string which has correspondence S next to each
other. This is Simple
write a program to find the longest word made of other words. For instance,
If my file has the following words (sorted):
test
tester
testertest
testing
testingtester
The longest word should be testingtester. Trie is the solution, what is the
best Order possible?
Best Regards
Ashish Goel
Think
Yea this is a Straight Cut Trie Question No Doubt.. Perhaps DWAG may be
taken into consideration..
T(O)=O(n) can be done easily.. ( By tracking Second and First Longest word
found soFar and updating otherwise accordingly)
Can someone do it better?
On Tue, May 22, 2012 at 6:15 PM, Ashish Goel
Anyways we need to sort all the words atleast once, one way is
To travel throught the list sorting each word and making a pair of the
orginal and the sorted word.
For Ex. If one of the original word in list is aanchal sorted is
aaachln. So store the pair aanchal, aaachln
Now sort this list of
@krishna : tracking just second and first longest word would be enough??
what if input has word which is made by repeating small word again and again
test
tester
testertest
testing
testingtester
testtesttesttesttest // added word
and by saying O(n) .. n= total number of alphabets in the file
yes ,longest word can be found while inserting each word it the TRIE.
*By tracking Second and First Longest word found** -- *confused me ...what
you were trying to say.
tracking can be done but become little difficult if input is something like
this :-
best
bestest
test
testbest
testbesttest
Thank you to understanding Me..
Well For Trie.. I don't hv to say much more to say except the basic need
which says Collect Common Prefix . If it didnt ring the bell.. than Hv a
look at strings MADAM and MADAMIAMADAM stored in your TRIE .. Just draw a
pictorial representation.
On Wed, May
think in term of following input case :-
best
test
testbest
than i guess you will come to knw why i got confused at first place.
*madammadam*
*testtesttest *
ignore this type of test case.
On Wed, May 23, 2012 at 12:40 AM, Prem Krishna Chettri
hprem...@gmail.comwrote:
Thank you to
i have an O(nlgn) solution in mind using O(n^2) memory
All the values can be thought as the following matrix
(a0+b0) (a0+b1) (a0+b2).(a0+bn-1)
(a1+b0) (a1+b1) (a1+b2).(a1+bn-1)
.
Given two sorted positive integer arrays A(n) and B(n). We define a
set S = {(a,b) | a in
A and b in B}. Obviously there are n^2 elements in S. The value of such
a pair is defined as Val(a,b) = a + b. Now we want to get the n pairs
from S with largest values. The tricky part is that we need an
Use Product of Primes as Hash function , this would give no collision in
case of anagrams.
On Tue, May 17, 2011 at 9:53 PM, Anand anandut2...@gmail.com wrote:
For any given word.
- Find the lexicographic ordering and calculate it hash.
- Find all permutation of the string
- Check each
How will BFS give a rearrangement ?
--
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
Given an English word in the form of a string, how can you quickly
find all valid
anagrams for that string (all valid rearrangements of the letters that
form valid
English words)?
--
*Piyush Sinha*
*IIIT, Allahabad*
*+91-8792136657*
*+91-7483122727*
Use BFS?
On Tue, May 17, 2011 at 11:36 AM, Piyush Sinha ecstasy.piy...@gmail.comwrote:
Given an English word in the form of a string, how can you quickly
find all valid
anagrams for that string (all valid rearrangements of the letters that
form valid
English words)?
--
*Piyush Sinha*
For any given word.
- Find the lexicographic ordering and calculate it hash.
- Find all permutation of the string
- Check each permutation if it's a valid word
- if so store it at the same hash index.
On Tue, May 17, 2011 at 7:16 AM, Ashish Goel ashg...@gmail.com wrote:
hash..
Best Regards
not clear, can u elaborate..
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
On Fri, May 13, 2011 at 7:15 PM, Bhavesh agrawal agr.bhav...@gmail.comwrote:
This problem can be solved using 2 heaps and the median can always be
accessed in O(1) time
Q. Numbers are randomly generated and stored into an (expanding) array. How
would you keep track of the median?
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
--
You received this message because you are subscribed to the Google Groups
Algorithm
This problem can be solved using 2 heaps and the median can always be
accessed in O(1) time ,the first node.
--
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
http://anandtechblog.blogspot.com/2010/11/find-next-higher-number-which-has-same.html
On Thu, May 12, 2011 at 10:52 PM, ArPiT BhAtNaGaR
arpitbhatnagarm...@gmail.com wrote:
if u knw the no. of 1's in no .
I mean can afford the complexity of finding no. of 1's of no.
den if no of 1'
in say
Using bit manipulation, implement add, subtract and multiply on two
integers. You cannot use any arithmetic operations, such as +, - or *.
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
--
You received this message because you are subscribed to the
Given an integer, print the next smallest and next largest numbers that have
the same number of 1’s in their binary representations
Best Regards
Ashish Goel
Think positive and find fuel in failure
+919985813081
+919966006652
--
You received this message because you are subscribed to the Google
if u knw the no. of 1's in no .
I mean can afford the complexity of finding no. of 1's of no.
den if no of 1'
in say 101011
is 4 den largest is00
smalest is 00
On Fri, May 13, 2011 at 8:38 AM, Ashish Goel ashg...@gmail.com wrote:
Given an integer,
24 matches
Mail list logo