Swap every two nodes in a single linked list
Posted by Jothi Basu
on November 09, 2017
with
No comments

Base2 number system conversion
Posted by Jothi Basu
on November 09, 2017
with
No comments

Reverse words in a line
Posted by Jothi Basu
on November 09, 2017
with
No comments

Next immediate greatest number which has all the digits
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given a integer, find the next immediate greatest number which has all the digits in the given number
public class Answer implements NextLargeNumberInterface {
@Override
public int GetNextLargeNumber(int num)
{
// WRITE YOUR CODE HERE
return ;
}
public static void main(String [] args)
{
// write code here to test
}
}
Example1:
Input:...
Run length encoding of a string
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given a string, you need to count the consecutive characters and show the count in the string for each character.
If there is only one character, you dont need to show the count.
public class Answer implements RunLengthEncodingInterface {
@Override
public String DoRunLengthEncoding(String str)
{
// WRITE YOUR CODE HERE
return ;
}
public...
Three Number Sum
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given a integer array and magic number, if there are any three numbers in the array
sum up to magic number return true, else return false.
Input:
Array: {-10, -9, -7, 5, 0, 99}
Arraylength: 6
MagicNumber: -17
Output: true
Input:
Array: {0, 1, 3, 5, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0}
Arraylength: 14
MagicNumber: 21
Output: false
public class...
Maximum ascending sequence length
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given a integer array, find the maximum length of ascending order sequence.
Input:
Array: {0, 1, 3, 5, 7, 0, 1, 2, 3, 4, 5, 6, 7, 0}
Arraylength: 14
Output:
Maximum Ascending sequence length: 7
Input:
Array: {2, -2, 2, -2, 2}
Arraylength: 5
Output:
Maximum Ascending sequence length: 1
public class Answer implements GetMaxAscSequenceLengthInterface...
Minimum distance between chars
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given a String, start char and end char, find the minimum distance between these two chars. If one of the strings is null or if the characters are not present we should return 0
Input 1:
String: "hello world"
Char1: ' '
Char 2: 'o'
Output: 2
Input 2:
String: "can I go to zoo"
Char1: 'o'
Char 2: 'o'
Output: 1
public class Answer implements...
Substring Same sequence
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given a String and substing, check whether the character in substring
are present in the main string in the SAME SEQUENCE. If yes, return true.
Input 1:
String: "Hello"
Substring: "elo"
Output: true
Input 2:
String: "hi friends"
Substring: "hiiids"
Output: false
public class Answer implements SubStringSameSequenceInterface {
@Override
...
Shuffle Merge two lists to form a new list
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given two linked lists of integers, shuffle merge those two lists to form a new linked list.
Example:
List1 : 1->3->5->7->9->10
List2: 2->4->6->8
Output: 1->2->3->4->5->6->7->8->9->10
Please note that after you pick elements alternatively from 2 lists, if one of the lists run out of elements,...
Remove Duplicates from the list
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given a linked list of integers, remove all the duplicate elements in the list. Elements are not necessarily in a sorted order.
Input: 1->2->2->3->4->3
Output: 1->2->3->4
Input: 2->2->2->2->2
Ouput: 2
Please note that the sequence should be maintained in the list after the duplicate removal.
public class...
Check if the linked list of integers is Palindrome
Posted by Jothi Basu
on November 09, 2017
with
1 comment

Given a singly linked list of integers, check if the values of the nodes are symmetrical(Palindrome).
Example:
1->23->45->6->45->23->1->null is symmetrical
1->23->4->32->1->null is not symmetrical
null is not symmetrical
1->null is symmetrical
public class Answer implements PalindromeListInterface
{...
Fully sort the list which is sorted in parts
Posted by Jothi Basu
on November 09, 2017
with
No comments

You have a singly linked list in which the first part and the second part(not exactly split in the middle) are sorted independently. You need to return a fully sorted list merging these two parts.
For example:
Input: 1->3->5->7->2->4->6->8
Output: 1->2->3->4->5->6->7->8
Your Answer.java need to implement...
Finding first non repeated character in the String using Hash map
Posted by Jothi Basu
on November 09, 2017
with
No comments

You are given a String and a hashmap. You need to use the Hashmap to find the first non repeated character in the String.
Input : aaabbcd Result: c
Input : null Result: ' '
Input: HelloKHello Result: K
You MUST use the hashmap passed as an argument in your solution. Otherwise, your test cases won't succeed.
Your Answer.java must implement the...
Ransom Note from Magazine using Hash table
Posted by Jothi Basu
on November 09, 2017
with
No comments

Kidnapper kidnaps you and writes a ransom note. He does not write it with hand, as handwriting can put him in, so reaches to a magazine at table and creates ransom note. We need to find out given ransom string and magazine string, is it possible to create given ransom note. Kidnapper can use individual characters of words.
We need to check if magazine...
Two numbers sum upto a given value using Hashmap
Posted by Jothi Basu
on November 09, 2017
with
No comments

Find if there are two elements in the array sum up to given value. You MUST use the hashmap passed as an argumentto solve the problem. If you don't your test cases will fail.
Input: {1, 2, 3, 4, 5} Value: 6 Output : true
Input: {1, 2, 3, 4, 5} Value: 2 Output : false
Your Answer.java should implement the following interface
import java.util.Map;...
Find all the extreme nodes of a binary tree in a zigzag order
Posted by Jothi Basu
on November 09, 2017
with
No comments

Find the extreme nodes of each level of Binary Tree in alternate order.
For example, for the following binary tree,
1
2 3
4 5 6 7
8
Should have output
1->2->7->8
Your Answer.java should implement following interface.
import java.util.List;
public interface ExtremeNodesInterface...
Check if Binary tree is symmetric
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given a binary tree you need to check if the left sub-tree from the root is a mirror image of the right sub-tree.
Please note that the symmetric nature is evaluated purely based on the structure of the tree and not based on any node values.
For example.
1
2 3
4 5
Is a symmetric binary tree.
Where as
1
2 ...
Boundary traverse a binary tree
Posted by Jothi Basu
on November 09, 2017
with
No comments

Find all the boundary nodes in a given binary tree. The boundary traversal should start from root, then go clockwise (root->right->left)
For example
1
2 3
4 4 6 7
8 9 1 1 2 3 3 4
This should return: 1->3->7->4->3->3->2->1->1->9->8->4->2
Your...
Check element in Binary Search Tree
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given a binary search tree with positive integers, check if given element is present in the given tree.
for eg:
14
/ \
/ \
3 17
/ \ / \
2 4 16 18
k = 9
Output: false
k = 16
Output: true
Here is sample Node.java (No need to upload this)
public class Node {
public int nodeValue;
public Node lChild;
...
Sum of Kth Largest Element in Binary Search Tree
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given a binary search tree with positive integers, find the sum of k largest elements of the BST.
(given k <= number of elements in BST)
for eg:
5
/ \
/ \
3 7
/ \ / \
2 4 6 8
k = 3
Sum = 6 + 7 + 8 = 21
Output: 21
Here is sample Node.java (No need to upload this)
public class Node {
public int nodeValue;...
Chocolate distribution problem
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given an array of n integers where each value represents number of chocolates in a packet. Each packet can have variable number of chocolates. There are m students, the task is to distribute chocolate packets such that :
1) Each student gets one packet.
2) The difference between the number of chocolates in packet with maximum chocolates and packet...
Print Palindromic Paths
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given a matrix containing lower alphabetical characters only, we need to find all palindromic paths in given matrix. A path is defined as a sequence of cells starting from top-left cell and ending at bottom-right cell. We are allowed to move to right and down only from current cell. You cannot go down diagonally.
Input : mat[][] = {"aaab”,
...
Minimum number of hops to reach end of array or beyond
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given an array of integers where each element represents the max number of steps that can be made forward from that element. Write a function to return the minimum number of jumps to reach the end of the array (starting from the first element). If an element is 0, then cannot move through that element.
Example:
Input: arr[] = {1, 3, 5, 8, 9, 2,...
Find the indices with anagram match
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given a String and a pattern find all the indices at which where we find an anagram match.
For example:
String : BACDGABCDA
Pattern : ABCD
We can find a match at {0, 5, 6}
In other words, if we find 4 consecutive characters from these indices, it contains the characters needed to match the pattern.
Your solution should implement the following interface:
public...
Find if there are three elements in BST that sums up to zero
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given a binary tree, check if there are three elements in binary tree which will sum up to zero. Return true if triplet exists, if not return false.
For example:
4
2 6
-5 3
In this binary tree, {-5, 2, 3} sum up to zero and you should return true.
0
-1 1
In this binary tree, {-1, 1, 0} sum...
Substring for given two chars
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given a string, determine the length of the smallest substring that contains exactly one occurrence of 'a' and one occurrence of 'b'
If there are no such substrings, return 0
Input : ahhhxb
Output : 6
Input : ahobpa
Output : 3
Input : qqqop
Output : 0
Answer
...
Bit flip - Find bit flip between two numbers
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given two integers a & b, determine how many bits need to be flipped in a to get the integer b
Input : 10 25
Output : 3
Input : 109 275
Output : 7
Answer
...
Find Max Continuous Repeating Char
Posted by Jothi Basu
on November 09, 2017
with
No comments

Given a string, return the character that is repeated the most number of times continuously.
Note: Do not count the character that occurs most overall, but count only the character that occurs most number of times continuously
Note: If two characters occur the same number of times continuously, return the first such in the string.
Input : AABBBC
Output...
Pattern Problem | Right angle Triangle
Posted by Jothi Basu
on November 01, 2017
with
No comments

Program to find FLAMES in java
Posted by Jothi Basu
on October 28, 2017
with
No comments

Odd numbers in odd index of array | Even numbers in even index of array
Posted by Jothi Basu
on October 23, 2017
with
No comments

Best Motivation
Posted by Jothi Basu
on October 23, 2017
with
No comments

Pattern Problem | Rectangle Pattern
Posted by Jothi Basu
on September 24, 2017
with
No comments

Pattern Problem | Alphabets
Posted by Jothi Basu
on September 22, 2017
with
No comments

Test Case #1
Enter limit:
Z
Enter difference:
1
Output
A
C
E
G
I
K
M
O
Q
S
U
W
Y
Test Case #2
Enter limit:
Z
Enter difference:
2
Output
AD
GJ
MP
SV
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #00cf90}
Y
Test Case...
Resume Templates
Posted by Jothi Basu
on September 11, 2017
with
No comments

Service
Posted by Jothi Basu
on March 10, 2017
with
No comments
