## Find first three largest elements in a given array

Objective: Given an array of integers, write an algorithm to find the first three largest elements in the array. Example: Int [] a = { 6, 8, 1, 9, 2, 1, 10}; Output: 10,...

Skip to content# Author: SJ

## Find first three largest elements in a given array

## Selection Sort – Java Implementation

## Print Number with its Sign in Java

## Find the nearest building which has bike | Find nearest specific vertex from source in a graph.

## Valid Brackets – Part 2 | Stack Method

## Find the roots of Quadratic Equation – Java Program

## Given two strings validate the output string

## Generate all the strings of length n from 0 to k-1.

## Find two smallest elements in a given array

## Front and Back Search in an Array

## Print all Unique elements in a given array

## Multiply with power of 2 without using pow() or * operator

## Find Number of reverse pairs in an array

## Find first two largest elements in a given array

## Calculate Logn base r – Java Implementation

@tutorialhorizon

Objective: Given an array of integers, write an algorithm to find the first three largest elements in the array. Example: Int [] a = { 6, 8, 1, 9, 2, 1, 10}; Output: 10,...

What is Selection Sort?? Selection sort is a simple sorting algorithm that builds the sorted array one item at a time. This sorting is efficient for small data sets, not efficient for large data...

Sometimes we need to print the numbers with its sign irrespective of number is positive (+) or negative(-). Example: X = 5, print = +5 Y = -8, print = -8 Say we need...

Objective: Given a matrix (NxN) which represents the buildings in community. You are in a building and you need a bike to travel. There are few buildings in community which has bikes which you...

Objective: Given a string containing just the characters ( , ) determine if the input string is valid. Example: ()()(()(()))() valid: true )()()( valid: false ()()) valid: false Approach: Earlier we discussed the solution which keeps...

Quadratic equation is in the form = ax2 + bx + c Discriminant (d) = b2 – 4ac Then roots are calculates using the equations below Root_1 = (-b + √d)/2a Root_2 = (-b...

Objective: Given two input strings and one output strings, validate if output string contains all the characters from both the input strings. Example: Input1 = “boy”, Input2 = “girl”, output = “gboilry” Result =...

Objective: Given two numbers, n and k (k>=n), write an algorithm to generate all the strings of length n drawn from 0 – k-1. Example: k = 2, n = 2Output: 0 0 0...

Objective: Given an array of integers, write an algorithm to find the two smallest elements in the array. Example: Int [] a = { 6, 8, 1, 9, 2, 10}; Output: 1, 2 Int...

Objective: Given an unsorted array of numbers and a number ‘x’, write a java program to search the number ‘x’ in the array and return its index else return -1. Example: Int [] a...

Objective: Given an array of integers which contains duplicates as well. Write a program to print all unique elements in the array. This problem is also referred as print all distinct elements in the...

Objective: Given a number n and k, Calculate n * k2 without using pow() or *operator. Example: N = 3, k = 4 N*k2 = 48 Approach: Bit Manipulation Left shift the number N...

Objective: Given an array of integers A[],find no of reverse pairs means no of (i, j) pairs where i < j and A[i]>A[j]. This problem is also asked as Count Inversions in an array....

Objective: Given an array of integers, write an algorithm to find the first two largest elements in the array. Example: Int [] a = { 6, 8, 1, 9, 2, 1, 10}; Output: 10,...

Objective: Given a number n and r, write a program to calculate Logrn Example: N = 32, r =2 Log232= 5 N = 64, r = 4 Log464= 3 Approach: Without using built-In function-...

%d bloggers like this: