reset password
Author Message
alomo
Posts: 70
Posted 22:26 Aug 03, 2009 |

My brute force solution.

 

Attachments:
Last edited by alomo at 18:25 Aug 04, 2009.
xieguahu
Posts: 50
Posted 19:57 Aug 04, 2009 |

I use contains() method to test the intersection instead of brutal force.

 

 

Attachments:
alomo
Posts: 70
Posted 21:23 Aug 04, 2009 |
xieguahu wrote:

I use contains() method to test the intersection instead of brutal force.

 

I think the using contains() is not the key that makes your program more effective than main. Your method tries to match substring of one string with another string, and as soon as a matching found, program does next loop-iteration (with a longer substring). If no matches for substrings of current length found, then no other (longer) substrings would match and therefore will not be checked.

In my case, program checks the length of matching part every time the commong beginning (fisrt symbols matching) found. In other words, my program would try to match 2-symbols substring, then do the same for substring of length=3, and again - for substring of length=2.

Last edited by alomo at 21:25 Aug 04, 2009.
p0941
Posts: 95
Posted 15:35 Aug 18, 2009 |

API:

findLCI(String S1, String S2) : void

1) It's not case sensitive for S1 or S2

2) S1 and S2 need to be seperated by comma ( , )

It will print out the result.

Attachments:
p0941
Posts: 95
Posted 15:38 Aug 18, 2009 |
I mean, elements in S1 or S2 should be seperated by a comma ( , ). 

p0941 wrote:

API:

findLCI(String S1, String S2) : void

1) It's not case sensitive for S1 or S2

2) S1 and S2 need to be seperated by comma ( , )

It will print out the result.

 

p0941
Posts: 95
Posted 15:45 Aug 18, 2009 |
Correction:  It's a class, not a function : findLCI S1, S2, where S1 and S2 are String type

p0941 wrote:
I mean, elements in S1 or S2 should be seperated by a comma ( , ). 

p0941 wrote:

API:

findLCI(String S1, String S2) : void

1) It's not case sensitive for S1 or S2

2) S1 and S2 need to be seperated by comma ( , )

It will print out the result.

 

 

p0941
Posts: 95
Posted 16:05 Aug 18, 2009 |

 findLCI(String s1, String s2)  function.   Return type: ArrayList.   This class accept command prompt argument, with s1 and s2's elements sepearated with comma, eg. P1, p2, P3, p4.

Attachments:
p0941
Posts: 95
Posted 12:13 Aug 27, 2009 |

Oops! One mistake.  Updated version here. 

Attachments: