Path Sum (Binary Tree Root to Leaf Path Sum)

Binary Tree Root to Leaf Path Sum Equal to a Given Number.

Given a binary tree and a sum, Determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.

If path is found then return true else return false.

Note: What is leaf node? Any node whose left and right children is null is known as leaf node.

For example –

In this Binary tree, there exist a path from root-to-leaf node whose sum is equal to the given sum (which is 16).

Now, suppose if the given value of sum is 12. Then in this case we simply return false. As the root-to-leaf node path does not exist in a Binary tree whose sum is equal to 12.

Roman to Integer

Given a Roman numeral, Write a code to convert roman to integer value.

Roman numerals are represented by seven different letters (I, V, X, L, C, D, M). These seven letters are used to make thousands of numbers.

Roman Numerals Symbol and It's decimal value.

For example –

Example 1 –

Input  : II , Output : 2

Example 2 –

Input  : XI , Output : 11

Example 3 – 

Input  : IV , Output : 4

Example 4 – 

Input : LVII , Output: 57 

NOTE : The given input is guaranteed to be within the range from 1 to 3999.

Check If a Linked List is Palindrome or Not

In this tutorial, I am going to discuss a programming question Palindrome linked list and it’s implementation using java code.

Given a singly linked list, Write a code that returns true if the given linked list is a Palindrome else return false.

For example –

Example 1 –

1 -> 3 -> 4 -> 3 -> 1 -> NULL

It’s a palindrome.

Example 2 –

1 -> 3 -> 4 -> NULL

It’s not a palindrome.

NOTE: We have to solve this problem in O(n) time complexity and without using any extra space.