✅ 1. Implement All Three Sorting Algorithms
🔹 Bubble Sort
🔹 Selection Sort
🔹 Insertion Sort
✅ 2. LeetCode Problems
🔸 Problem 1: Sort Colors
Sort an array containing only 0s, 1s, and 2s.
Use Dutch National Flag Algorithm (O(n) time, O(1) space)
🔸 Problem 2: Check if Array Is Sorted and Rotated
Return
trueif array is sorted and rotated at most once.
🔍 Logic:
Count how many times arr[i] > arr[i+1]. If it happens more than once, it's not valid.
🧠 Summary of Day 4
-
✅ Bubble, Selection, Insertion Sort implemented
-
✅ LeetCode problems solved
-
Dutch National Flag (0s, 1s, 2s)
-
Check Sorted & Rotated
-
No comments:
Post a Comment