Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CODE IN JAVA, USE THE CODE TEMPLATE PROVIDED ON THERIGHT coderbyte medium Time left: Unlimited time Array Challenge Have the function ArrayChallenge (strArr) read the

CODE IN JAVA, USE THE CODE TEMPLATE PROVIDED ON THERIGHT

image

coderbyte medium Time left: Unlimited time Array Challenge Have the function ArrayChallenge (strArr) read the array of strings stored in strArr, which will contain 2 elements: the first element will be a sequence of characters representing a word, and the second element will be a long string of comma- separated words, in alphabetical order, that represents a dictionary of some arbitrary length. For example: strArr can be: ["worlcde", "apple,bat,cat,goodbye,hello, yellow,why,world"]. Your goal is to determine the minimum number of characters, if any, can be removed from the word so that it matches one of the words from the dictionary. In this case, your program should return 2 because once you remove the characters "c" and "e" you are left with "world" and that exists within the dictionary. If the word cannot be found no matter what characters are removed, return -1. Examples Input: new String[] {"baseball", "a, all, b, ball, bas, base, cat, code, d, e, quit,z"} Output: 4 Input: new String[] {"apbpleeeef", "a, ab, abc, abcg,b,c,dog,e,efd, zzzz"} Output: 8 Java 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 import java.util.*; import java.io.*; class Main { } public static String ArrayChallenge(String[] strArr) { // code goes here return strArr [0]; } Vim Emacs public static void main (String[] args) { // keep this function call here. Scanner s = new Scanner(System.in); System.out.print(ArrayChallenge (s.nextLine())); }

Step by Step Solution

3.38 Rating (167 Votes )

There are 3 Steps involved in it

Step: 1

The answer provided below has been developed in a clear step by step manner Step 1 Here is code to s... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Electrical Engineering questions

Question

1. Let a, b R, a Answered: 1 week ago

Answered: 1 week ago

Question

Where do we go from here?

Answered: 1 week ago