Category: c / c++
The n-queens puzzle is the problem of placing n queens on an n×n chessboard such that no two queens attack each other. Given an integer n, return all distinct …
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity. Example: Input: Output: 1->1->2->3->4->4->5->6 There are many algorithms that we can use …
Given an array arr, replace every element in that array with the greatest element among the elements to its right, and replace the last element with -1. After doing …
Given a binary tree, return the sum of values of its deepest leaves. Example 1: Input: root = Output: 15 Constraints: The number of nodes in the tree is …
Given an array A of integers, return the length of the longest arithmetic subsequence in A. Recall that a subsequence of A is a list A, A, …, A …