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...
-
In the case of Bill Often, Bill Early, what information might have been obtained from inquiries? From tests of controls? From observations? From confirmations?
-
CVP analysis, sensitivity analysis Hoot Washington is the newly elected leader of the Republican Party. Media Publishers is negotiating to publish Hoots Manifesto, a new book that promises to be an...
-
Refer to the information in Problem 21-1B. Tohono Companys actual income statement for 2017 follows. Required 1. Prepare a flexible budget performance report for 2017. Analysis Component 2. Analyze...
-
Fernandez Corporation purchased a truck at the beginning of 2012 for $50,000. The truck is estimated to have a salvage value of $2,000 and a useful life of 160,000 miles. It was driven 23,000 miles...
-
When discussing possible purchase of a fixed immediate annuity, not discussing the full range of available annuitization options and the implications of choosing one over another, particularly with...
-
Create a concept map that depicts your assumptions and findings of the theory-practice gap. You are a staff nurse working in an intensive care unit and assigned to care for a 75-year-old African...
-
Sheldon Company, with fixed costs of $45,000 has sales of $100,000 and a variable cost rate of 30%. If Sheldon decreases the selling price of its product by 5% with no change in fixed costs or the...
-
2. Which graph of the following functions does not have vertical asymptotes? a. y = cotx b. y = tanx C. secx d. y= cost
-
1 f(x) is defined as follows, find (a) f(-1), (b) fo) and ( if x=0 f(x) = if x=0 3x+1 if x>0 (a) f(-1)=(Simplify your answer.) (b) f(0)=(Simplify your answer.) (c) f(3)=(Simplify your answer.)
-
Find the slope of the secant line between the values 1 and 2 for the function given below. == f(x)=x+3; = c, x2 = c + h; c>-3 The slope is Simplify your answer completely and in such a way that the...
-
1 Plan your communication by completing the table below. Who am I communicating to? Meeting 1 (e.g. with Project team) Meeting 2 (e.g. with customers) What is the purpose of my communication? ...
-
Let y=sin(5x). If Ax = 0.2 at x = 0, use linear approximation to estimate Ay Ay = Find the percentage error error = % Round the percent to two decimal places if needed.
-
1 Winter's Toyland has a debt-to-equity ratio of 0.65. The pretax cost of debt is 8.7 percent and the required return on assets is 16.1 percent. What is the cost of equity if you ignore taxes? (Round...
-
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...
-
Whenever Aliza buys a flashlight, she also always buys exactly two batteries along with it. Any more than two batteries will serve no purpose, because she will not be able to use them in the...
-
State governments in India levy a value-added tax on the sale of goods. The rate of this sales tax varies by type of good and by state. In Maharashtra, the general rate of sales tax is \(12.5 \%\),...
-
Divit enjoys watching team sports and considers tickets to kabaddi and badminton games to be perfect substitutes. Show his preference map. What is his utility function?
Study smarter with the SolutionInn App