Skip to content

Instantly share code, notes, and snippets.

View KeshariPiyush24's full-sized avatar
🏠
Working from home

Piyush Keshari KeshariPiyush24

🏠
Working from home
View GitHub Profile
SMALLEST INFORMATION UNIT:
1 NIBBLE = 4 BITS
1 BYTE = 8 BITS
1 KILOBYTE (KB) = 8 KILOBITS = 1,024 BYTES = 2¹⁰ BYTES
1 MEGABYTE (MB) = 8 MEGABITS = 1,048,576 BYTES = 2²⁰ BYTES
1 GIGABYTE (GB) = 8 GIGABITS = 1,073,741,824 BYTES = 2³⁰ BYTES
1 TERABYTE (TB) = 8 TERABITS = 1,099,511,627,776 BYTES = 2⁴⁰ BYTES
1 PETABYTE (PB) = 8 PETABITS = 1,125,899,906,842,624 BYTES = 2⁵⁰ BYTES
Programming Languages Levels:
@KeshariPiyush24
KeshariPiyush24 / Notes.md
Created September 29, 2024 18:40
Sort Stack using Recursion

Sorting a Stack using Recursion

Intuition

The core idea behind sorting a stack using recursion is to:

  1. Remove elements from the stack one by one.
  2. Recursively sort the remaining stack.
  3. Insert the removed element at the correct position in the sorted stack.
@KeshariPiyush24
KeshariPiyush24 / Notes.md
Last active September 29, 2024 18:21
Reverse A Stack Using Recursion

Reversing a Stack using Recursion

Intuition

The core idea behind reversing a stack using recursion is to:

  1. Remove elements from the stack one by one.
  2. Recursively reverse the remaining stack.
  3. Insert the removed element at the bottom of the reversed stack.
@KeshariPiyush24
KeshariPiyush24 / Notes.md
Last active September 23, 2024 06:18
Check Prime or not

Prime Number Testing: Methods, Complexity, and Implementations

1. Basic Concept

A prime number is a natural number greater than 1 that is only divisible by 1 and itself.

2. Efficient Prime Testing Methods

2.1 6k ± 1 Method

@KeshariPiyush24
KeshariPiyush24 / Notes.md
Created September 21, 2024 10:14
349. Intersection of Two Arrays
@KeshariPiyush24
KeshariPiyush24 / Notes.md
Created September 21, 2024 10:06
Row with max 1s

Question: Row with max 1s

Intution: Not exactly binary search but we can utilize the fact that it the row is sorted. We have to use 2 pointers approach.

Time Complexity: $$O(n + m)$$

Space Complexity: $$O(1)$$

Solution:

@KeshariPiyush24
KeshariPiyush24 / Notes.md
Created September 21, 2024 09:36
Frequency In A Sorted Array
@KeshariPiyush24
KeshariPiyush24 / Notes.md
Created September 21, 2024 08:29
Implement Lower Bound

Question: Implement Lower Bound

Intution:

Time Complexity: $$O(log(n))$$

Space Complexity: $$O(1)$$

Solution:

@KeshariPiyush24
KeshariPiyush24 / Notes.md
Last active September 21, 2024 08:27
Implement Upper Bound

Question: Implement Upper Bound

Intution:

Time Complexity: $$O(log(n))$$

Space Complexity: $$O(1)$$

Solution:

@KeshariPiyush24
KeshariPiyush24 / Notes.md
Created September 21, 2024 05:39
153. Find Minimum in Rotated Sorted Array