Tag Archives: C

Lowest Common Ancestor in a BST: GeeksforGeeks

Problem link: http://www.geeksforgeeks.org/lowest-common-ancestor-in-a-binary-search-tree/

Problem Statement:
Given values of two nodes in a Binary Search Tree, write a c program to find the Lowest Common Ancestor (LCA). You may assume that both the values exist in the tree. You can assume that the nodes are present in the tree.
Continue reading

Advertisements

2’s complement : Hackerrank

Problem link: https://www.hackerrank.com/challenges/2s-complement

Problem Statement:
One of the basics of Computer Science is knowing how numbers are represented in 2’s complement. Imagine that you write down all numbers between A and B inclusive in 2’s complement representation using 32 bits. How many 1’s will you write down in all ?
Continue reading

10001st prime: Project Euler Problem 7

Problem link: http://projecteuler.net/problem=7

Problem Statement:
By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

What is the 10 001st prime number?

Continue reading

Smallest multiple: Project Euler Problem 5

Problem link: http://projecteuler.net/problem=5

Problem Statement:
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.

What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?

Continue reading

Largest palindrome product: Project Euler Problem 4

Problem link: http://projecteuler.net/problem=4

Problem Statement:
A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.

Find the largest palindrome made from the product of two 3-digit numbers.

Continue reading