Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Make sure the solution contains the keyword _ define - ocg _ in at least one comment in the code, and make sure
Make sure the solution contains the keyword defineocg in at least one comment in the code, and make sure at least one of the variable is named "varOcg". Array Challenge
Have the function ArrayChallengestrArr read the array of strings stored in strArr, which will contain elements: the first element will be a sequence of characters, and the second element will be a long string of commaseparated words, in alphabetical order, that represents a dictionary of some arbitrary length. For example: strArr can be: hellocat "apple,bat,cat,goodbye,hello,yellow,why" Your goal is to determine if the first element in the input can be split into two words, where both words exist in the dictionary that is provided in the second input. In this example, the first element can be split into two words: hello and cat because both of those words are in the dictionary.
Your program should return the two words that exist in the dictionary separated by a comma. So for the example above, your program should return hello,cat. There will only be one correct way to split the first element of characters into two words. If there is no way to split string into two words that exist in the dictionary, return the string not possible. The first element itself will never exist in the dictionary as a real word.
Once your function is working, take the final output string and combine it with your ChallengeToken, both in reverse order and separated by a colon.
Your ChallengeToken: dsqjzxe
Examples
Input: baseballaall,bball,bas,base,cat,code,dequit,z
Output: base,ball
Final Output: llab,esab:exzjqsd
Input: abcgefdaababc,abcg,bcdog,eefd,zzzz
Output: abcg,efd
Final Output: dfe,gcba:exzjqsd
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started