Given: Array of size n Problem Constraints1 <= N <= 10001 <= A (element) <= 1000 Example InputInput : 1 2 3 4 5 Example OutputOutput : 15 public class…
Given: Integer array of size N Constraints 1 <= N <= 10001 <= array elements <= 1000 Example InputInput :10 50 40 80 Example OutputOutput : 80 10 Solution public…
Searching Searching an element in an unsorted arraySearching an element in a sorted array Sorting Sort an arraySort list of words in lexicographical orderMerge two sorted array Other Union of…
Program to implemnet stack using array public class StackImpWithArray { static final int MAX=2; int top; int bucket[]=new int[MAX]; StackImpWithArray(){ top=-1; } boolean push(int val){ if(top<MAX-1){ top++; bucket[top]=val; System.out.println("Value Pushed");…
Find two such nodes whose sum is equal to the target provided class Solution { /* This is the Node class definition class Node { public Node left; public Node…
Given a no find no of trailing zeroes present in the factorial of that number public class TrailingZeroes { public static void main(String[] args) { System.out.println(trailingZeroesInFactorial(10)); System.out.println(trailingZeroesInFactorial(45)); System.out.println(trailingZeroesInFactorial(50)); } static…
Check if teh given set of parenthesis are valid import java.util.HashMap; import java.util.Map; import java.util.Stack; public class ValidParentheses { public static void main(String[] args) { System.out.println(isValid("()[]{}")); } static boolean isValid(String…
Given an array containing elements in form of 0, 1, and 2 sort the array import java.util.Arrays; public class SortArrayWithZeroesOnesAndTwos { public static void main(String[] args) { System.out.println(Arrays.toString(getSortedArray(new int[]{2,1,0,0,1,2,0,2,1}))); }…