random-dsa.js
v1.0.2
Published
This is a Javascript which gives you random dsa question each time you query it.
Downloads
228
Readme
Random DSA Question Picker
A simple utility to fetch a random Data Structures and Algorithms (DSA) question based on category or from the entire list. This package is useful for practice sessions, coding challenges, or learning DSA concepts.
Installation
To install this package, use npm:
npm install random-dsa.js
Usage
Import the package
import { randomDSA } from 'random-dsa.js';
Fetch a random question from a specific category
You can specify a category to get a random DSA question. Available categories include:
- Array and String
- Linked List
- Stack and Queue
- Binary Tree
- Searching and Sorting
- Graphs
- Dynamic Programming
const question = randomDSA('Array and String');
console.log(question);
// Example output: { id: 1, title: "Reverse a string", category: "Array and String" }
Fetch a random question from all categories
If no category is specified, the function will return a random question from the entire list:
const question = randomDSA();
console.log(question);
// Example output: { id: 12, title: "Implement stack using arrays", category: "Stack and Queue" }
Available Categories
You can pass any of the following categories as an argument to randomDSA
:
Array and String
Linked List
Stack and Queue
Binary Tree
Searching and Sorting
Graphs
Dynamic Programming
Example
import { randomDSA } from 'random-dsa.js';
const randomQuestion = randomDSA("Graphs");
console.log(randomQuestion);
// Output: { id: 19, title: "Implement Depth First Search (DFS) and Breadth First Search (BFS)", category: "Graphs" }
const randomQuestionWithoutCategory = randomDSA();
console.log(randomQuestionWithoutCategory);
// Output: Random question from any category
Contributing
If you'd like to contribute, feel free to submit a pull request or open an issue. We welcome improvements, new features, and additional questions!
License
This project is licensed under the MIT License.
This README provides the following:
- Overview: A brief description of the package.
- Installation: A step-by-step guide on how to install the package.
- Usage: Code examples demonstrating how to use the package with or without specifying a category.
- Available Categories: A list of all categories users can pass to the function.
- Contributing: Information for people interested in contributing to the package.
- License: The license under which the package is released.