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

Programming Exercises

Write a function to convert a deeply nested object into a flat object.

Hard

Problem Statement

Write a function to convert a deeply nested object into a flat object.

Sample Input

{ a: { b: { c: 1 }, d: 2 }, e: 3 }

Sample Output

{ 'a.b.c': 1, 'a.d': 2, e: 3 }

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
function flattenObject(obj: any, parentKey: string = "", result: any = {}): any { // Your logic here }
Log in or sign up to run or submit your code.Log inSign up
Input
{ a: { b: { c: 1 }, d: 2 }, e: 3 }
Expected Output
{ 'a.b.c': 1, 'a.d': 2, e: 3 }