USING IntelliJ, Create project named CompSciQuiz; Implement the classes identified below; Code Specification: We are solving a
Question:
USING IntelliJ,
- Create project named CompSciQuiz;
- Implement the classes identified below;
Code Specification:
We are solving a classic interview problem, finding the longest prefix in an ArrayList of Strings.
The problem statement is:
You must find the longest common prefix in an array of Strings. If there is no common prefix, return an empty string (i.e. ""). If there is a common prefix, return it as a String:
Example: in this array ["flower","flow","flight"], we would return "fl" Example: in this array ["flower","flow"], we would return "flow" Example: in this array ["dog","racecar","car"], we would return "" Example: in this array [], we would return "" as there are no strings at all
Step 1:
Below are two classesLongestCommonPrefix andLongestCommonPrefixTest. Create the corresponding java files (they must have the same name), and ensure that you can run your tests.
Step 2:
Write new test where you pass an empty ArrayList to the findLongestCommonPrefix method. This test will fail, in fact, it will through an error. You need to figure out how to fix this, hint, it should return an empty string ("") if there are no elements in the ArrayList. Include at least one assert in the test.
Step 3:
Find a way to fix the code so that the test passes.
Step 4 (Extra Credit):
Write test that would fail given the code below and correct the code so that it passes, this must include at least assert in the test.
Artificial Intelligence A Modern Approach
ISBN: 9780134610993
4th Edition
Authors: Stuart Russell, Peter Norvig