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 = ...

Solved Leetcode 2140. Solving Questions With Brainpower

source: https://leetcode.com/problems/solving-questions-with-brainpower/description/ Solving Questions With Brainpower You are given a 0-indexed 2D integer array questions where questions[i] = [pointsi, brainpoweri]. The array describes the questions of an exam, where you have to process the questions in order (i.e., starting from question 0) and make a decision whether to solve or skip each question. Solving question ...

Solved! Leetcode 1498. Number of Subsequences That Satisfy the Given Sum Condition

source: https://leetcode.com/problems/number-of-subsequences-that-satisfy-the-given-sum-condition/description/ Number of Subsequences That Satisfy the Given Sum Condition You are given an array of integers nums and an integer target. Return the number of non-empty subsequences of nums such that the sum of the minimum and maximum element on it is less or equal to target. Since the answer may be too ...

Solved! Leetcode 1046. Last Stone Weight

source: https://leetcode.com/problems/last-stone-weight/description/ Last Stone Weight You are given an array of integers stones where stones[i] is the weight of the ith stone. We are playing a game with the stones. On each turn, we choose the heaviest two stones and smash them together. Suppose the heaviest two stones have weights x and y with x ...

Solved! Leetcode 1312. Minimum Insertion Steps to Make a String Palindrome

source: https://leetcode.com/problems/minimum-insertion-steps-to-make-a-string-palindrome/description/ Minimum Insertion Steps to Make a String Palindrome Given a string s. In one step you can insert any character at any index of the string. Return the minimum number of steps to make s palindrome. A Palindrome String is one that reads the same backward as well as forward. Example 1: Input: ...

Solved! Leetcode 879. Profitable Schemes

source: https://leetcode.com/problems/profitable-schemes/description/ Profitable Schemes There is a group of n members, and a list of various crimes they could commit. The ith crime generates a profit[i] and requires group[i] members to participate in it. If a member participates in one crime, that member can’t participate in another crime. Let’s call a profitable scheme any subset ...

Solved! Leetcode 1372. Longest ZigZag Path in a Binary Tree

source: https://leetcode.com/problems/longest-zigzag-path-in-a-binary-tree/description/ Longest ZigZag Path in a Binary Tree You are given the root of a binary tree. A ZigZag path for a binary tree is defined as follow: Choose any node in the binary tree and a direction (right or left). If the current direction is right, move to the right child of the ...

Solved! Leetcode 946. Validate Stack Sequences

source: https://leetcode.com/problems/validate-stack-sequences/description/ Validate Stack Sequences Given two integer arrays pushed and popped each with distinct values, return true if this could have been the result of a sequence of push and pop operations on an initially empty stack, or false otherwise. Example 1: Input: pushed = [1,2,3,4,5], popped = [4,5,3,2,1] Output: true Explanation: We might ...

Solved! Leetcode 1431. Kids With the Greatest Number of Candies

source: https://leetcode.com/problems/kids-with-the-greatest-number-of-candies/description/ Kids With the Greatest Number of Candies There are n kids with candies. You are given an integer array candies, where each candies[i] represents the number of candies the ith kid has, and an integer extraCandies, denoting the number of extra candies that you have. Return a boolean array result of length n, ...