Beautiful Year in java

It seems like the year of 2013 came only yesterday. Do you know a curious fact? The year of 2013 is the first year after the old 1987 with only distinct digits. Now you are suggested to solve the following problem: given a year number, find the m ...

Implementing Selection Sort in java

Given an array arr of size n, containing positive integers. You need to sort the elements of array using the Selection Sort algorithm. Input Format First line contains an integer n which is the size of array& ...

Sort the string in descending order in java

Given a string str containing only lower case alphabets, the task is to sort it in lexicographically-descending order. Input The line inputs str ,a string. Constraints: 1 ≤ length of string < 10^5 Output Print the modified strin ...

Accio Sort in java

You're given a statement in the form of a string 'str' that has no more than 9 words, with each word suffixed by a unique number ranging from 1 to N, where N is the total number of words in the sentence. Your goal is to reorder the words in 'str' ac ...

Petya and Strings in java

Little Petya loves presents. His mum bought him two strings of the same size for his birthday. The strings consist of uppercase and lowercase Latin letters. Now Petya wants to compare those two strings lexicographically. The case of the letter does ...

Delete a node from BST in java

You are given N nodes and have to form BST from it.You are given a key K, delete node with value K.Note: If K is not present in the BST, do not modify the BST. Input Format The first line inputs N, the number of nodes and K, key.The second lin ...

Search a node in BST in java

You are given the root of a binary search tree (BST) and an integer val. Find the node in the BST that the node's value equals val and return true. If such a node does not exist, return false. Input The first line inputs N, the number of no ...

Tree Inorder Traversal in java

You are given the number of nodes present in the tree. You have to input the nodes and form a Binary Search Tree (BST). BST should be formed in way like: Let us consider an array named Val having the values of the nodes. Here, V ...

Postorder Traversal in java

You are given the number of nodes present in the tree. You have to input the nodes and form a Binary Search Tree (BST). BST should be formed in way like: Let us consider an array named Val having the values of the nodes. Here, V ...

Tree Preorder Traversal in java

You are given the number of nodes present in the tree. You have to input the nodes and form a Binary Search Tree (BST). After forming the BST, print the Preorder traversal of the BST. Input Format Line 1 contains integer n denoting number of n ...