Question: IN JAVA!!!! Write a method that returns the longest common prefix between a phrase A and a phrase B. If the two phrases do not

IN JAVA!!!!

Write a method that returns the longest common prefix between a phrase A and a phrase B. If the two phrases do not share a common prefix, return the empty string no prefix. Your method should either take two strings or two char arrays as arguments (A, B) and return a string.

Test your method in the main with these three pairings.

Example

A: snowball

B: snowcone

Return: snow

A: river

B: rover

Return: r

A: monday

B: tuesday

Return: no prefix

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!