← Questions

Count subarrays whose product is a perfect square

0
MicrosoftCodingLast asked Oct 2026

A coding interview question asked in Microsoft's HackerRank assessment, last asked Oct 2026. It tests prefix xor, bitmask and number theory.

Call a non-empty contiguous subarray special when the product of its elements has an odd number of positive divisors. Given an array of positive integers, count the special subarrays.

Sign in to unlock this question

The full prompt, the worked answer and your own canvas or code with the AI tutor. New accounts get 5 credits: each one unlocks a question for good.

Where it's asked

What it tests

prefix xor · bitmask · number theory · hash map

Your code and the AI tutor open when you unlock this question.