Pregunta de entrevista de Sysdig

Special Array I from leetcode: https://leetcode.com/problems/special-array-i Special Array II from leetcode: https://leetcode.com/problems/special-array-ii

Respuesta de la entrevista

Anónimo

3 jul 2025

During the second I stupidly insisted using the solution of part 1, and it wasn't the optimal one. I then proposed a solution based on indexes of "unspecialty" checking then if those indexes where in queries intervals. It turned out later that, even if it was asymptotically optimal it wasn't the most elegant and neither the best one. The trick is to change the initial array assigning the same value and increment it every time an index of "unspecialty" is found. Then queries are checked just by comparing the values under the two indexes: if they're the same they the subspecialty requirement is satisfied, false otherwise.