Design and implement a Google Calendar-like application.
Core Features:
interface Event {
id: string;
title: string;
start: Date;
end: Date;
attendees: string[];
}
class Calendar {
addEvent(event: Event): void;
editEvent(id: string, updates: Partial<Event>): void;
deleteEvent(id: string): void;
}
// Unit Tests
describe('Calendar', () => {
test('should add event', () => {
// Test event creation
});
test('should handle overlapping events', () => {
// Test conflict resolution
});
test('should validate event dates', () => {
// Test date validation
});
});
Requirements:
Design CLI tool for fetching currency exchange rates.
Interface:
interface ExchangeRate {
date: string;
from: string;
to: string;
rate: number;
}
interface CLIArgs {
startDate: string;
endDate: string;
fromCurrency: string;
toCurrency: string;
}
class ExchangeRateCLI {
async fetchRates(args: CLIArgs): Promise<ExchangeRate[]>;
formatOutput(rates: ExchangeRate[]): string;
}
Requirements:
Track user location based on flight history.
Data Structure:
interface Flight {
userId: string;
departureTime: Date;
arrivalTime: Date;
departureAirport: string;
arrivalAirport: string;
}
function getUserLocation(
flights: Flight[],
userId: string,
timestamp: Date
): string
Example:
flights = [
{
userId: "123",
departureTime: "2024-01-01T10:00:00Z",
arrivalTime: "2024-01-01T12:00:00Z",
departureAirport: "JFK",
arrivalAirport: "LAX"
}
]
getUserLocation(flights, "123", "2024-01-01T11:00:00Z")
// Returns: "In flight JFK->LAX"
Implement React component with multiple input types.
Component Interface:
interface Props {
input?: boolean | any[] | any;
}
const DynamicComponent: React.FC<Props> = ({ input }) => {
// Live date/time if input undefined/false
// Array elements if input is array
// Input value otherwise
}
// Example Usage:
<DynamicComponent /> // Live date/time
<DynamicComponent input={[1,2,3]} /> // Array elements
<DynamicComponent input="hello" /> // Direct value
Requirements:
Convert snake_case to camelCase in code files.
Function:
function convertToCamelCase(code: string): string
Examples:
Input: "__variable_one__ _variable_two"
Output: "__variableOne__ _variableTwo"
Input: "_hello_world"
Output: "_helloWorld"
Requirements:
- Preserve leading/trailing underscores
- Handle multiple underscores
- Maintain other formatting
Design system for managing door access control.
Core Components:
interface User {
id: string;
accessLevel: AccessLevel;
department: string;
}
interface Door {
id: string;
location: string;
requiredAccess: AccessLevel;
}
class AccessControl {
grantAccess(user: User, door: Door): boolean;
logAccess(user: User, door: Door, granted: boolean): void;
updateAccessLevel(user: User, level: AccessLevel): void;
}
Requirements:
1. Access Levels
- Hierarchical permissions
- Department-based access
- Time-based restrictions
2. Security Features
- Access logging
- Breach detection
- Emergency override
3. System Design
- Real-time validation
- Offline capability
- Audit trail