Tripadvisor Phone Interview - Program to count all squares in matchstick grid

Question: First design a data structure to represent the below grid formed using match sticks. Using this data structure as an input write a program to count all the possible squares in the below example figures.

image
Answer: 16

image
Answer: 2

Comments (2)