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

Programming Exercises

Implement a singleton class in TypeScript.

Hard

Problem Statement

Implement a singleton class in TypeScript.

Sample Input

None

Sample Output

Singleton instance created
Are both instances equal? true

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
class Singleton { private static instance: Singleton; private constructor() { // Private constructor logic } static getInstance(): Singleton { // Your logic here }
Log in or sign up to run or submit your code.Log inSign up
Input
None
Expected Output
Singleton instance created
Are both instances equal? true