Tag: C++ coding exercise
Given an integer n, your task is to count how many strings of length n can be formed under the following rules: Each character is a lower case vowel …
Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. Example: Input: 3 Output: , , ] Walk and Turn …
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 …
Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2->->3 Output: 1->2->3->4 Example 2: Input: -1->5->3->4->0 Output: -1->0->3->4->5 The Merge sort performs …
Catalan numbers are popular in Combinatoric Mathematics. Many interesting counting problems tend to be solved using the Catalan numbers. The first few Catalan numbers are: 1, 1, 2, 5, …