Skip to content

nullram/nix_play_assessment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TASK no.1: Kth Largest Element Finder

This project implements an efficient kth largest element finder using the quickselect algorithm.

Requirements

  • Node.js
  • TypeScript compiler (tsc)

Note on Dependencies

The only npm dependencies are TypeScript and Node.js type definitions, which are used for development and compilation only. The runtime code uses Node.js built-ins only; you can run the compiled JavaScript directly with Node from the output folder. see sample below

Run Tests

tsc --target ES2020 --module commonjs --outDir output/task1 task1/kthLargest.ts task1/kthLargest.test.ts
node output/task1/kthLargest.test.js

You can also run:

npm run test:task1

Evaluation Criteria Mapping

  • Correctness and edge cases: Input validation throws on empty arrays or invalid rank, and tests cover nums=[], rank=0, rank>n, and nums=[1], rank=1.
  • Efficiency: Quickselect provides average $O(n)$ time with $O(1)$ extra space; no Array.sort() is used.
  • Readability and modularity: Logic is split into findKthLargestElement, partition, swap, and randomInt with JSDoc comments.
  • Test coverage: 5+ assertions include duplicates, rank=1, rank=n, and invalid inputs.

TASK no.2: LRU Cache with Expiration

This task implements an LRU cache with optional per-entry expiration (TTL).

Requirements

  • Node.js
  • TypeScript compiler (tsc)

Note on Dependencies

The only npm dependencies are TypeScript and Node.js type definitions, which are used for development and compilation only. The runtime code uses Node.js built-ins only; you can run the compiled JavaScript directly with Node from the output folder. see sample below

Run Tests

tsc --target ES2020 --module commonjs --outDir output/task2 task2/lruCache.ts task2/lruCache.test.ts
node output/task2/lruCache.test.js

You can also run:

npm run test:task2

Evaluation Criteria Mapping

  • Correct LRU behavior: Tests cover eviction and recency updates.
  • Expiration logic: Tests verify TTL expiry and overwrite behavior.
  • Robustness: Tests cover capacity=0, negative capacity, and invalid keys.
  • Complexity: get/put are $O(1)$ average with hash map + doubly linked list.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published