Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].
The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.
You must write an algorithm that runs in…
Given an integer numRows, return the first numRows of Pascal’s triangle.
In Pascal’s triangle, each number is the sum of the two numbers directly above it as shown:
Problem statement taken from: https://leetcode.com/problems/pascals-triangle
Input: numRows = 5
Output: [ , [1, 1], [1, 2, 1], [1, 3, 3, 1]…
Given an integer array nums of length n and an integer target, find three integers in nums such that the sum is closest to target.
Return the sum of the three integers.
You may assume that each input would have exactly one solution.
Problem statement taken from: https://leetcode.com/problems/3sum-closest
Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list’s nodes (i.e., only nodes themselves may be changed.)
Problem statement taken from: https://leetcode.com/problems/swap-nodes-in-pairs
Input: head = [1, 2, 3, 4]
Output: [2, 1…
Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.
If such an arrangement is not possible, it must rearrange it as the lowest possible order (i.e., sorted in ascending order).
The replacement must be in place and use only constant extra memory.
Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.
You must write an algorithm with O(log n) runtime complexity.
Problem statement taken from: https://leetcode.com/problems/search-insert-position
Merge two sorted linked lists and return it as a sorted list. The list should be made by splicing together the nodes of the first two lists.
Problem statement taken from: https://leetcode.com/problems/merge-two-sorted-lists
Input: l1 = [1, 2, 4], l2 = [1, 3, 4]
Output: [1, 1, 2, 3, 4…
Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.
The overall run time complexity should be O(log (m+n)).
Problem statement taken from: https://leetcode.com/problems/median-of-two-sorted-arrays
Input: nums1 = [1, 3], nums2 = 
Output: 2.00000 …
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
Problem statement taken from: https://leetcode.com/problems/generate-parentheses
Input: n = 3
Output: ["((()))", "(()())", "(())()", "()(())", "()()()"]
Input: n = 1
- 1 <= n <= 8
A brute force…