Home
Gaurav's GitHub Page
Cancel

Integer to Roman

PROBLEM DESCRIPTION Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M. Symbol Value I 1 V 5 X 10 L 50 C ...

Roman to Integer

PROBLEM DESCRIPTION Given a roman numeral, convert it to an integer. leetcode SOLUTION APPROACH 1 If there are two characters left in the string s AND the integer value of first roman characte...

H-Index

PROBLEM DESCRIPTION Given an array of integers citations where citations[i] is the number of citations a researcher received for their ith paper, return the researcher’s h-index. According to the...

Best Time to Buy and Sell Stock II

PROBLEM DESCRIPTION You are given an integer array prices where prices[i] is the price of a given stock on the ith day. On each day, you may decide to buy and/or sell the stock. You can only hold...

Design Patterns: Index

DESIGN PATTERNS Creational Design Patterns :diamond_shape_with_a_dot_inside: Singleton: A pattern that ensures a class has only one instance. :building_construction: Builder: A pattern to cons...

Design Pattern: Observer

OBSERVER The Observer design pattern is a behavioral design pattern that establishes a one-to-many dependency between objects, so that when one object changes its state, all the dependent objects ...

Remove Duplicates from Sorted Array II

PROBLEM DESCRIPTION Given an integer array nums sorted in non-decreasing order, remove some duplicates in-place such that each unique element appears at most twice. The relative order of the eleme...

Design Pattern: Strategy

STRATEGY The Strategy design is a behavioral design pattern that allows us to define different strategies (or ways) to solve a problem and switch between them easily. It helps us encapsulate each ...

Merge Sorted Array

PROBLEM DESCRIPTION You are given two integer arrays nums1 and nums2, sorted in non-decreasing order, and two integers m and n, representing the number of elements in nums1 and nums2 respectively....

Design Pattern: Flyweight

FLYWEIGHT The Flyweight pattern is a design pattern that helps optimize memory usage by sharing common data between multiple objects. It is particularly useful when dealing with objects that have ...