hcl logo

Hcl Interviews

1 experience7 reads
HCL | Backend Engineer
hcl logo
Hcl
Backend Engineer
July 10, 20257 reads

Summary

I was presented with a problem requiring me to determine which build targets need to be rebuilt based on dependency information and a list of changed files.

Full Experience

Problem

Write a function that takes build dependency information and a list of files that have changed since the last build, and returns a list of targets that need to be rebuilt. The build dependencies are make-like target-dependency pairs, for example:

[   ["prog", "a.o"],   ["prog1", "b.o"],   ["a.o", "a.c"],   ["b.o", "b.c"],   ["prog2", "b.o"],   ["prog2", "c.o"],   ["c.o", "c.c"],]

For this example, if a.c changes, then we need to rebuild a.o and then prog1, but not prog2. But if b.c changes, we would need to rebuild b.o, which would trigger a rebuild for both prog1 and prog2.

The resulting target list should contain unique values. I.e. no duplicates

The order of the resulting list is unimportant. NOTE: The test harness will check against a specific order, and might fail, you can manually verify the results though as test cases are very small.

Interview Questions (1)

Q1
Build Dependency Rebuild Targets
Data Structures & AlgorithmsMedium

Problem

Write a function that takes build dependency information and a list of files that have changed since the last build, and returns a list of targets that need to be rebuilt. The build dependencies are make-like target-dependency pairs, for example:

[   ["prog", "a.o"],   ["prog1", "b.o"],   ["a.o", "a.c"],   ["b.o", "b.c"],   ["prog2", "b.o"],   ["prog2", "c.o"],   ["c.o", "c.c"],]

For this example, if a.c changes, then we need to rebuild a.o and then prog1, but not prog2. But if b.c changes, we would need to rebuild b.o, which would trigger a rebuild for both prog1 and prog2.

The resulting target list should contain unique values. I.e. no duplicates

The order of the resulting list is unimportant. NOTE: The test harness will check against a specific order, and might fail, you can manually verify the results though as test cases are very small.

Have a Hcl Interview Experience to Share?

Help other candidates by sharing your interview experience. Your insights could make the difference for someone preparing for their dream job at Hcl.