Page Navigator
Square interview questions · Medium · Coding round · 6 tests
Design a PageNavigator that models the visible page-number strip for a paginated
UI. Given a total number of pages and a fixed window size, return the consecutive page numbers
that should be shown for a requested current page.
Interface
class PageNavigator {
constructor(totalPages: number, windowSize: number);
getVisiblePages(currentPage: number): number[];
}Run your code with Ctrl+Enter to see results.