CODE IN JAVA, USE THE CODE TEMPLATE PROVIDED ON THERIGHT coderbyte medium Time left: Unlimited time Array
Fantastic news! We've Found the answer you've been seeking!
Question:
CODE IN JAVA, USE THE CODE TEMPLATE PROVIDED ON THERIGHT
Transcribed Image Text:
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())); } 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())); }
Expert Answer:
Answer rating: 100% (QA)
The answer provided below has been developed in a clear step by step manner Step 1 Here is code to s... View the full answer
Related Book For
Income Tax Fundamentals 2013
ISBN: 9781285586618
31st Edition
Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill
Posted Date:
Students also viewed these electrical engineering questions
-
JAVA PROGRAMMING / CODE IN JAVA 3. Create a binary expression tree for a postfix expression. 4. Write a program to evaluate a postfix expression and convert a postfixexpression to infix expression.
-
Use a cash flow template to construct a cash flow plan for Laura. What is her monthly cash flow? Laura's Financial Report Income Teacher, monthly after-tax income: $5,000 Tutor, monthly after-tax...
-
Please read chapter 11 that i have provided a drop box link below. its approximately 20 pages. after careful reading, write at least a three page summary of the chapter. the report is expected to be...
-
Pettit Printing Company has a total market value of $100 million, consisting of 1 million shares selling for $50 per share and $50 million of 10 percent perpetual bonds now selling at par. The...
-
As an auditor for the CPA firm of Agler and Carl, you encounter the following situations in auditing different clients. 1. Desi Corporation is a closely held corporation whose stock is not publicly...
-
At December 31, the records of Seacrest Enterprises provided the following selected and incomplete data: Common stock (par $ 1; no changes during the current year). Shares authorized, 10,000,000....
-
Consider the following data: Required Use the above data to prepare the operating cash flow section of a consolidated statement of cash flows, using the indirect method. Consolidated net income.......
-
Here are comparative balance sheets for Syal Company. Additional information: 1. Net income for 2014 was $103,000. 2. Depreciation expense was $32,000. 3. Cash dividends of $45,000 were declared and...
-
The fieldwork for the December 31, 2018 audit of Schmidt Corporation ended on March 17, 2019. The financial statements and auditor's report were issued on March 29, 2019. In each of the material...
-
Enhance the Treasury Yield Rates database file to perform a database query that finds the rate associated with any date and term.
-
Queue, unlike a stack, has the first in, first out principle that is data added first will be removed first. In most languages, this data structure is already implemented in some language library...
-
Taveras Corporation is currently operating at 5 0 % of its available manufacturing capacity. It uses a job - order costing system with a plantwide predetermined overhead rate based on machine -...
-
Huron Company produces a commercial cleaning compound known as Zoom. The direct materials and direct labor standards for one unit of Zoom are given below: Standard Quantity or Hours Standard Price or...
-
Cordova manufactures three types of stained glass windows, cleverly named Products A, B, and C. Information about these products follows: Product A Product B Product C $ Sales price $51.00 $ 61.00...
-
Ashton Company, a distributor of exercise equipment, is preparing a cash budget for December. It provided the following information: a. The cash balance on December 1 is $50,600. b. Actual sales for...
-
Salmone Company reported the following purchases and sales for its only product. Salmone uses a perpetual inventory system. Determine the cost assigned to cost of goods sold using LIFO. Date...
-
Velocity field V = ay + b where a = 3 s - 1 , b = 2 ft / s and dimension are in feet. Find the Volume flow rate and Momentum flux through the inclined surface
-
Why should you not model a decision variable as a random variable with a probability distribution?
-
Mark owns his home and has a $250,000 mortgage related to his purchase of the residence. When his daughter went to college in the fall of 2012, he borrowed $20,000 through a home equity loan on his...
-
Amy is a calendar-year taxpayer reporting on the cash basis. Please indicate how she should treat the following items for 2012: a. She makes a deductible contribution to an IRA on April 15,...
-
Karim Depak received a Form 1099-B showing the following stock transactions and basis during 2012: None of the stock is qualified small business stock. Calculate Karim's net capital gain or loss...
-
The Pauli spin matrices in quantum mechanics are given by the following matrices: \(\sigma_{1}=\left(\begin{array}{ll}0 & 1 \\ 1 & 0\end{array} ight), \sigma_{2}=\left(\begin{array}{cc}0 & -i \\ i &...
-
Find the eigenvalue(s) and eigenvector(s) for the following: a. \(\left(\begin{array}{ll}4 & 2 \\ 3 & 3\end{array} ight)\) b. \(\left(\begin{array}{ll}3 & -5 \\ 1 & -1\end{array} ight)\) c....
-
For the matrices in the previous problem, compute the determinants and find the inverses, if they exist.
Study smarter with the SolutionInn App