Given two strings, one is a subsequence if all of the elements of the first string...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given two strings, one is a subsequence if all of the elements of the first string occur in the same order within the second string. They do not have to be contiguous in the second string, but order must be maintained. For example, given the string 'I like cheese', the words ('I', 'cheese') are one possible subsequence of that string. Words are space delimited. Given two strings, s and t, where t is a subsequence of s, report the words of s, missing in t (case sensitive), in the order they are missing. Example s = I like cheese' t = 'like' Then 'like' is the subsequence, and ['I', 'cheese'] is the list of missing words, in order. Function Description Complete the function missingWords in the editor below. missingWords has the following parameter(s): string s: a sentence of space-separated words string t: a sentence of space-separated words Returns: string[i]: an array of strings that contains all words in s that are missing from t, in the order they occur within s Constraints • Strings s and t consist of English alphabetic letters (i.e., a-z and A-Z), dash '-', and spaces only. • All words are delimited by a space 1s/t/s/s/ ≤ 106 1 ≤ length of any word in sorts 15 • It is guaranteed that string t is a subsequence of string s. ● ● • Strings s and t consist of English alphabetic letters (i.e., a-z and A-Z), dash '-', and spaces only . All words are delimited by a space • 1 ≤/t/ ≤ /s/ ≤ 106 • 1 ≤ length of any word in s or t≤ 15 • It is guaranteed that string t is a subsequence of string s. ▼ Input Format for Custom Testing Input from stdin will be processed as follows and passed to the function. The first line contains a string s. The first line contains a string t. ▾ Sample Case 0 Sample Input STDIN I am using Hacker Rank to improve programming programming' am Hacker Rank to improve Sample Output I using programming Explanation The missing words are: → → Function s = 'I am using Hacker Rank to improve t = am Hacker Rank to improve' 2. using 3. programming Add these words in order to the array ["", "using", "programming"], then return this array as the answer. Given two strings, one is a subsequence if all of the elements of the first string occur in the same order within the second string. They do not have to be contiguous in the second string, but order must be maintained. For example, given the string 'I like cheese', the words ('I', 'cheese') are one possible subsequence of that string. Words are space delimited. Given two strings, s and t, where t is a subsequence of s, report the words of s, missing in t (case sensitive), in the order they are missing. Example s = I like cheese' t = 'like' Then 'like' is the subsequence, and ['I', 'cheese'] is the list of missing words, in order. Function Description Complete the function missingWords in the editor below. missingWords has the following parameter(s): string s: a sentence of space-separated words string t: a sentence of space-separated words Returns: string[i]: an array of strings that contains all words in s that are missing from t, in the order they occur within s Constraints • Strings s and t consist of English alphabetic letters (i.e., a-z and A-Z), dash '-', and spaces only. • All words are delimited by a space 1s/t/s/s/ ≤ 106 1 ≤ length of any word in sorts 15 • It is guaranteed that string t is a subsequence of string s. ● ● • Strings s and t consist of English alphabetic letters (i.e., a-z and A-Z), dash '-', and spaces only . All words are delimited by a space • 1 ≤/t/ ≤ /s/ ≤ 106 • 1 ≤ length of any word in s or t≤ 15 • It is guaranteed that string t is a subsequence of string s. ▼ Input Format for Custom Testing Input from stdin will be processed as follows and passed to the function. The first line contains a string s. The first line contains a string t. ▾ Sample Case 0 Sample Input STDIN I am using Hacker Rank to improve programming programming' am Hacker Rank to improve Sample Output I using programming Explanation The missing words are: → → Function s = 'I am using Hacker Rank to improve t = am Hacker Rank to improve' 2. using 3. programming Add these words in order to the array ["", "using", "programming"], then return this array as the answer.
Expert Answer:
Answer rating: 100% (QA)
Python program that creates and test the function missingWords that takes two strings as inputs and ... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
In 2024, the Westgate Construction Company entered into a contract to construct a road for Santa Clara County for $10,000,000. The road was completed in 2026. Information related to the contract is...
-
Would SQL queries lead to performance bottlenecks in an Oracle Database and how would you eliminate this problem?
-
Case Study: Quick Fix Dental Practice Technology requirements Application must be built using Visual Studio 2019 or Visual Studio 2017, professional or enterprise. The community edition is not...
-
The indicating instruments with linear scale is Electrostatic instrument a O Thermocouple instrument.bo Dynamometer instrument C PMMC.d O
-
Write a MATLAB script to plot the efficiency as a function of electric power output for the induction generator of Problem 6.17 as the slip varies from -0.5 to -3.2 percent. Assume the generator to...
-
Debt Investment, Held-to-Maturity, Impairments, IFRS. Repeat E16-17 assuming Gretta Company reports under IFRS.
-
Suppose college students are given two options. With option A, the price a student pays for a class is always the equilibrium price. For example, if the equilibrium price to take Economics 101 is...
-
What did Brown and BWNS do well in this situation? What could have been done better? MINI CASE Reggie Brown, B&W Nuclear Service Companys (BWNS) project manager for Nita Light and Powers Green Meadow...
-
1 2 34 What is "SWOT analysis? How do you carry it for a technical educationalinstitute? What is corporate planning? Explain the process of corporate planning? Discuss the process of strategy...
-
S&P Enterprises has provided data from the first three months of the year. The Controller has asked you to prepare the Cash Budget and the related Schedules for Expected cash collections and Payments...
-
Do you agree with idea that speech is special in the sense that speech perception is fundamentally different from ordinary auditory perception that we have previous discussed? Explain.
-
The table shows the relationship for a hypothetical firm between its advertising expenditure on various platforms and the quantity of its output that it expects to sell at a fixed price of 400 per...
-
Housing prices in the United States decline dramatically and remain depressed for several months. Using an IS-MP graph, explain what happens to the macroeconomic equilibrium in the United States....
-
The cross-price elasticity values for three sets of products are listed in the table below. What can you conclude about the relationships between each of these sets of products? Cross-price...
-
You are given the following cost data: If the price of output is 12, how many units of output will this firm produce? What is the total revenue? What is the total cost? Will the firm operate or shut...
-
A mining companys land concession in Angola incorporates five major mines that extract copper. The productivity of each mine is as follows: The company must decide how many mines to operate. Assume...
-
This map shows the locations of Wawa (in yellow) and Sheetz (in red) convenience stores in eastem PA. Both stores sell gasoline and are considering where to place gasoline holding tanks to serve the...
-
Suppose you are comparing just two means. Among the possible statistics you could use is the difference in means, the MAD, or the max min (the difference between the largest mean and the smallest...
-
Write a program that will compute statistics for eight coin tosses. The user will enter either an h for heads or a t for tails for the eight tosses. The program will then display the total number and...
-
Modify the program in the previous exercise so that it reads the name of the file from the keyboard. Previous exercise Write a program that will write the Gettysburg Address to a text file. Place...
-
Suppose we want to implement a drawing program that creates various shapes using keyboard characters. Implement an abstract base class DrawableShape that knows the center (two integer values) and the...
-
List the five major components of a computer system.
-
What is hardware?
-
What encoding scheme is extensive to represent all the characters of all the languages in the world?
Study smarter with the SolutionInn App