A good string is a string or a substring that starts with the character "g" and ends with the character "d". For a given string, write a program to find the number of "good substrings" of a given string. Note - A substring of a string is a contiguous subsequence of that string. The list of all non-empty substrings of the string "apple" would be "apple", "appl", "pple", "app", "ppl", "ple", "ap", "pp", "pl", "le", "a", "p", "p", "T", and "e" There will be multiple test cases running so the Input and Output should match exactly as provided. The base output variable result is set to a default value of -404 which can be modified. Additionally, you can add or remove these output variables. Input Format The first line contains the string S. Sample Input godk - denotes S Constraints. 1 <= len|S| <= 100 Output Format The output contains a single integer denoting the number of good substrings of the given string. Sample Output

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
A good string is a string or a substring that starts with the character "g" and ends with the character "d".
For a given string, write a program to find the number of "good substrings" of a given string.
Note
- A substring of a string is a contiguous subsequence of that string.
The list of all non-empty substrings of the string "apple" would be "apple", "appl", "pple", "app", "ppl", "ple", "ap", "pp", "pl", "le", "a", "p", "p", "I", and "e"
There will be multiple test cases running so the Input and Output should match exactly as provided.
The base output variable result is set to a default value of -404 which can be modified. Additionally, you can add or remove these output variables.
Input Format
The first line contains the string S.
Sample Input
godk - denotes S
Constraints
1 <= len|S| <= 100
Output Format
The output contains a single integer denoting the number of good substrings of the given string.
Sample Output
1
Explanation
In the given string, only one substring "god" is good.
Hence, the answer is 1
Transcribed Image Text:A good string is a string or a substring that starts with the character "g" and ends with the character "d". For a given string, write a program to find the number of "good substrings" of a given string. Note - A substring of a string is a contiguous subsequence of that string. The list of all non-empty substrings of the string "apple" would be "apple", "appl", "pple", "app", "ppl", "ple", "ap", "pp", "pl", "le", "a", "p", "p", "I", and "e" There will be multiple test cases running so the Input and Output should match exactly as provided. The base output variable result is set to a default value of -404 which can be modified. Additionally, you can add or remove these output variables. Input Format The first line contains the string S. Sample Input godk - denotes S Constraints 1 <= len|S| <= 100 Output Format The output contains a single integer denoting the number of good substrings of the given string. Sample Output 1 Explanation In the given string, only one substring "god" is good. Hence, the answer is 1
1- function solution(str) {
2
5678AWN
3
4 }
6 function main() {
9
10
12-
13
Addr
15
16
17
19
// write your code here
return 0;
}
var readline = require("readline");
var rl = readline.createInterface (process. stdin, process.stdout);
rl.prompt();
let args = []
rl.on("line", (input) => {
});
args.push(input)
if(args.length = 1) {
main();
console.log(solution (args[0]));
rl.close();
I
Transcribed Image Text:1- function solution(str) { 2 5678AWN 3 4 } 6 function main() { 9 10 12- 13 Addr 15 16 17 19 // write your code here return 0; } var readline = require("readline"); var rl = readline.createInterface (process. stdin, process.stdout); rl.prompt(); let args = [] rl.on("line", (input) => { }); args.push(input) if(args.length = 1) { main(); console.log(solution (args[0])); rl.close(); I
Expert Solution
steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Knowledge Booster
Time complexity
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education