Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Write a function to validate a deeply nested object structure against a given schema.

Hard

Problem Statement

Write a function to validate a deeply nested object structure against a given schema.

Sample Input

Object: { name: "John", details: { age: 30, city: "New York" } }
Schema: { name: "string", details: { age: "number", city: "string" } }

Sample Output

Object is valid: true

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
function validateObject(obj: any, schema: any): boolean { // Your logic here }
Log in or sign up to run or submit your code.Log inSign up
Input
Object: { name: "John", details: { age: 30, city: "New York" } }
Schema: { name: "string", details: { age: "number", city: "string" } }
Expected Output
Object is valid: true