Amazon | OA2 | Number Of Clusters
Anonymous User
4237

Position: New Grad 2021
Location: US

Insert a weird backstory about any of Amazon's operations
Given a 2-d array , elements only consist of the lowecase alphabets - a , b or c.
Find the number of clusters (same lowecase alphabets that connect 4-directionally - up , down ,left or right).

Example 1

a a a
b b b

Output : 2

Example 2

b b b c a a
b b b b b b

Output : 3

Example 3

a a a
c c b
a b a

Output : 6

Method Signature - int findNumOfClusters(vector<string> grid)

Comments (7)