Solved! Leetcode 2130. Maximum Twin Sum of a Linked List

source: https://leetcode.com/problems/maximum-twin-sum-of-a-linked-list/description/ Maximum Twin Sum of a Linked List In a linked list of size n, where n is even, the ith node (0-indexed) of the linked list is known as the twin of the (n-1-i)th node, if 0 <= i <= (n / 2) – 1. For example, if n = 4, then node ...

Solved Leetcode 1721: Swapping Nodes in a Linked List

source: https://leetcode.com/problems/swapping-nodes-in-a-linked-list/description/ Swapping Nodes in a Linked List You are given the head of a linked list, and an integer k. Return the head of the linked list after swapping the values of the kth node from the beginning and the kth node from the end (the list is 1-indexed). Example 1: Input: head = ...

Leetcode 379: Design Phone Directory

Design a phone directory that initially has maxNumbers empty slots that can store numbers. The directory should store numbers, check if a certain slot is empty or not, and empty a given slot. Implement the PhoneDirectory class: PhoneDirectory(int maxNumbers) Initializes the phone directory with the number of available slots maxNumbers.int get() Provides a number that ...