- Task 1: Solve the "Median of Two Sorted Arrays" problem on LeetCode.
- Write a function that takes two sorted arrays of integers and returns the median of the two sorted arrays.
- Log the median for a few test cases, including edge cases.
- Task 2: Solve the "Merge k Sorted Lists" problem on LeetCode.
- Write a function that takes an array of k linked lists, each linked list is sorted in ascending order, and merges all the linked lists into one sorted linked list.
- Create a few test cases with linked lists and log the merged list.
- Task 3: Solve the "Trapping Rain Water" problem on LeetCode.
- Write a function that takes an array of non-negative integers representing an elevation map where the width of each bar is 1, and computes how much water it can trap after raining.
- Log the amount of trapped water for a few test cases.
- Task 4: Solve the "N-Queens" problem on LeetCode.
- Write a function that places n queens on an n×n chessboard such that no two queens attack each other, and returns all distinct solutions to the n-queens puzzle.
- Log the distinct solutions for a few test cases.
- Task 5: Solve the "Word Ladder" problem on LeetCode.
- Write a function that takes a begin word, an end word, and a dictionary of words, and finds the length of the shortest transformation sequence from the begin word to the end word, such that only one letter can be changed at a time and each transformed word must exist in the word list.
- Log the length of the shortest transformation sequence for a few test cases.
- Median of Two Sorted Arrays Script: Write a script that includes a function to find the median of two sorted arrays and logs the median.
- Merge k Sorted Lists Script: Create a script that includes a function to merge k sorted linked lists and logs the merged list.
- Trapping Rain Water Script: Write a script that includes a function to calculate the amount of trapped rainwater and logs the result.
- N-Queens Script: Create a script that includes a function to solve the N-Queens problem and logs the distinct solutions.
- Word Ladder Script: Write a script that includes a function to find the shortest transformation sequence in a word ladder and logs the sequence length.
By the end of these activities, students will:
- Solve complex LeetCode problems.
- Apply advanced problem-solving skills to implement efficient algorithms.
- Understand and handle edge cases in hard algorithmic solutions.
- Gain confidence in solving hard-level coding challenges on LeetCode.