Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

There are N cars, numbered from 0 to N - 1 . Each of them has some of the M possible optional features, numbered from

There are N cars, numbered from 0 to N-1. Each of them has some of the M possible optional features, numbered from 0 to M-1, for example: voice control, keyless entry, sunroof, blind spot detection, etc. The features of a car are described as a string of M characters, where the K- th character being '1' denotes that the car has the K-th possible feature and '0' denotes that it does not.
Files
task1
soluti
test-in
Two cars are similar if their descriptions differ by at most one feature. For example: "01101" and "01001" are similar, because they differ only by feature number 2. On the other hand, "01101" and "11110" are not similar, because they differ in feature numbers 0,3 and 4.
Each car from the following set is similar to "011": "011","111","001","010". Notice that cars "011" and "011" are similar as their set of features exactly the same.
We want to suggest to potential customers alternative cars to the one under consideration. In order to do that, for each individual car, calculate the number of other cars to which it is similar (differ from it by at most one feature).
Write a function:
class Solution { public int[] solution(String[] cars); }
Test Output
that, given an array cars consisting of N strings, returns an array of integers denoting, for every car in cars, the number of other similar cars.
Examples:
1. Given cars =['100","110","010","011","100"], the answer should be [2,

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

Understanding Databases Concepts And Practice

Authors: Suzanne W Dietrich

1st Edition

1119827949, 9781119827948

More Books

Students also viewed these Databases questions

Question

What are the requirements for effective learning at work?

Answered: 1 week ago