Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved 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

 

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.

Step by Step Solution

3.54 Rating (157 Votes )

There are 3 Steps involved in it

Step: 1

Python program that creates and test the function missingWords that takes two strings as inputs and ... 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

Java An Introduction To Problem Solving And Programming

Authors: Walter Savitch

8th Edition

0134462033, 978-0134462035

More Books

Students also viewed these Programming questions

Question

Zetrene $10,000 25. de .wibee You Zetrene $10,000 25. de .wibee You

Answered: 1 week ago

Question

What are the APPROACHES TO HRM?

Answered: 1 week ago