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.

Minimum Size Subarray Sum

Minimum Size Subarray Sum (Smallest subarray whose sum is greater than or equal to target).

Given an array of positive integers and a positive number k. Find the smallest contiguous subarray whose sum is either greater than or equal to k. If no subarray is found then return 0.

For example –

Example 1 –

  Input :  {7, 2, 1, 1, 6, 5},  k = 11

Output:  2 ( subarray {6, 5} has the minimum length )

Example 2 –

  Input : {1, 4, 3},   k = 12

Output: 0 (No subarray is possible)