Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ Third question, programming help, please provide code solution Files solution.cpp x task3 // you can use includes, for example: There is a list A

C++ Third question, programming help, please provide code solution

image text in transcribed
Files solution.cpp x task3 // you can use includes, for example: There is a list A made of N strings, each of length 2. Two strings can be connected // #include ether if the letter ending the first string is the same as the letter beginning the solution.cpp test-input.txt // you can write to stdout for debugging purposes, e.g. second string. For example, the two strings "ab" and "bc" can be connected, as "ab" // cout &A) { // Implement your solution here same as the first letter of the next string, e.g. "ab"-"ba"-"ac"-"cb". For every K from 0 to N-1, check if all the strings A[O], ..., A[K] can be connected together. Strings can be reordered, but must not be reversed. Write a function: string solution(vector &A); that, given an array A consisting of N strings, each of length 2, returns a string of length N. The K-th character of the string should be '1' if strings A[0], ..., A[K] can be connected into a single string, or '0' otherwise. Examples: 1. For A = ['he", "II", "lo", "el"], the function should return "1001": ['he ] is already a single string - 1 ['he , "Il"] cannot be connected - 0 . ['he , "Il", "lo"] cannot be connected - 0 ['he , "Il", "lo", "el"] can be connected into "he"-"el"-"Il"-"lo" - 1 To leave editor use Ctrl + Shift + M Language Version: 2. For A = ["ab", "ba", "bq"], the function should return "111". Strings can be connected Test Output into a single string for every K = 0, 1 and 2. Note that ["ab", "ba"] can be connected into either "ab"-"ba" or "ba"-"ab". 3. For A = ['ee", "ea", "eg"], the function should return "110". Write an efficient algorithm for the following assumptions: . N is an integer within the range [1..100,000]; each string in A has length 2 and consists only of lowercase letters (a-z). Copyright 2009-2023 by Codility Limited, All Rights Reserved. Unauthorized copying, publication or

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Define marketing.

Answered: 1 week ago

Question

What are the traditional marketing concepts? Explain.

Answered: 1 week ago

Question

Define Conventional Marketing.

Answered: 1 week ago

Question

Define Synchro Marketing.

Answered: 1 week ago

Question

Define marketing concepts.

Answered: 1 week ago