The N queens puzzle is the problem of placing N chess queens on an N × N chessboard so that no two queens threaten each other. Thus, a solution requires that no two queens share the same row, column, or diagonal.
This article covers the stack implementation in Java. A stack is a linear data structure which follows the LIFO (last-in first-out) principle. That means the objects can be inserted or removed only at one end of it also called as top.
Write a C program to print current date and time in standard output.
Sieve of Eratosthenes is a very efficient algorithm that can be used in most coding competitions involving prime numbers in the range of a given number n. The algorithm starts off by assuming that all the numbers in the range 2 to n are prime. Now we traverse the list starting from 2 to …
Write a program to calculate n’th Fibonacci number where n is a given positive number. Fibonacci sequence is characterized by the fact that every number after the first two is the sum of the two preceding ones. For example, consider below sequence – 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, …
Write a program to print all numbers between 1 to N without using semicolon.
Given two integers, swap them without using any third variable.
A queue is a linear data structure which follows the FIFO (first-in first-out) principle. That means the object which is inserted first will be the first one out, followed by the object which was inserted next. The queue supports below core operations –
What should be the if condition in below code snippet, so that output would be “Hello World”. if “condition” printf (“Hello”); else printf(“World”);
Given three integers, find maximum and minimum number between them without using conditional statement or ternary operator.
Given a large number N, find all positive numbers less than N that can be represented as sum of two cubes for at-least two different pairs. In other words, find all positive numbers M less than given number N that can be expressed as M = (a^3 + b^3) = (c^3 + d^3) for …