Question: Comcast, Recently Asked Online Assessments in 21Nov, 2025 | First Day of Subsequence | Pet Supply Store | Electric Wire Grid
0
Entering edit mode

Question 1: First Day of Subsequence

Problem Statement:

Bob has a string S and Alice has a string T. Each day, Bob takes his string S and appends it to the final string K. For example, if S is "ab" then K will also be "ab" (on the first day), then on the second day, K becomes "abab". On the third day, K becomes "ababab" and so on.

Your task is to help Alice find and return an integer value, representing the day when the string K contains T as a subsequence for the first time.

Note:

  • A subsequence is a sequence that can be derived from another sequence by deleting some or no elements without changing the order of the remaining elements.
  • Do not alter the order of the string while choosing a subsequence.

Input Specification:

  • input1: A string value S, representing the string Bob has.
  • input2: A string value T, representing the string Alice has.

Output Specification:

Return an integer value representing the day when the string K contains T as a subsequence for the first time.

Question 2: Pet Supply Store

Problem Statement:

A pet supply store uses specific unit symbols to represent quantities of different pet items, which are defined as follows:

  • 'f' = bags of dog food  ₹800 per unit.
  • 't' = liters of fish tank water  ₹50 per unit.
  • 'c' = cat toys  ₹200 per unit.
  • 'b' = boxes of pet treats  ₹1200 per unit.

You are given a string S that encodes the list of pet items, and your task is to find and return an integer value representing the total cost of all items in S.

Note: If a unit appears without a number before it, it is assumed to represent a single unit (i.e., quantity = 1). If a number is not followed by a valid unit, treat it as a plain number and add it directly to the total cost.

Input Specification:

  • input1: A string S consisting of the quantities and units of 'f', 't', 'c', and 'b'.

Output Specification:

  • Return an integer value representing the total cost of all items in S.

Question 3: Electric Wire Grid

Problem Statement:

You are given an integer array A of size N, where each element represents the current in a wire segment. You can invert (multiply by -1) up to X segments, but two consecutive segments cannot be inverted together due to stability constraints.

Your task is to find and return an integer value representing the maximum possible net current after applying the best inversions. If no valid inversion can be made, return the sum of the original array.

Input Specification:

  • input1: An integer value N representing the number of segments.
  • input2: An integer value X representing the maximum inversion segment.
  • input3: An integer array A representing the current values.

Output Specification:

  • Return an integer value representing the maximum possible net current after applying the best inversions. If no valid inversion can be made, return the sum of the original array.
        ADD COMMENTlink 3 days ago admin 1.8k

        Login before adding your answer.

        Similar Posts
        Loading Similar Posts