1622588700

# SKP's Algorithms and Data Structures #9: Java Problem: Monkeys in the Garden

In a garden, trees are arranged in a circular fashion with an equal distance between two adjacent trees. The height of trees may vary. Two monkeys live in that garden and they were very close to each other. One day they quarreled due to some misunderstanding. None of them were ready to leave the garden. But each one of them wants that if the other wants to meet him, it should take maximum possible time to reach him, given that they both live in the same garden.

The conditions are that a monkey cannot directly jump from one tree to another. There are 30 trees in the garden. If the height of a tree is H, a monkey can live at any height from 0 to H. Let’s say he lives at the height of K then it would take him K unit of time to climb down to the ground level. Similarly, if a monkey wants to climb up to K height it would again take K unit of time. The time to travel between two adjacent trees is 1 unit. A monkey can only travel in a circular fashion in the garden because there is a pond at the center of the garden.

So the question is where should two monkeys live such that the traveling time between them is maximum while choosing the shortest path between them in any direction clockwise or anti-clockwise. You have to answer only the maximum traveling time.

Input Format

The First Line consists of Total Number of Trees (N). Each of the Following N Lines contains the Height of Trees in a Clockwise Fashion.

Constraints

1 <= Total Trees <= 30

1 <= Height Of Trees(H) <= 10000

Output Format

You must Print an Integer which will be the Maximum Possible Travel Time.

[Explanation of the Solution]

Surprisingly, this Problem is under the Object-Oriented Programming (OOP) Section of the Problems! Initially, I was on the Lookout for a ‘Mathematically Superior’ Solution. But Couldn’t Reach Anywhere — In the End, I have a Simple Solution at O(n²). Iterate through Each ‘Combination of Trees’ and then Find the Clockwise and Anti-Clockwise Distance — At Each Iteration, the Minimum of the Two is Added to the Length of Each Tree. If this Value is Greater than the Maximum Path Length (Previous Iterations) — Replace the Maximum Path Length.

#algorithms #core java #data structures

1621103940

## SKP's Algorithms and Data Structures

Continuing on the Quick Revision of Important Questions for My Interviews. These Are Good Puzzles or Questions Related to Data Structures.

My Article Series on Algorithms and Data Structures in a Sort of ‘Programming Language Agnostic Way’. Few of the Algorithms and Data Structures in C, Few in C++, and Others in Core Java. Assorted Collection for Learning, Revising, Revisiting, Quick Refresh, and a Quick Glance for Interviews. You May Even Include them Directly for Professional or Open Source Efforts. Have Included Explanation Only for Few of These! Hope these turn out to be Really Helpful as per the Author’s Intention.

#### Data Structure — Interview Questions

#java #core java #data structures #dijkstra #core java basics #data structure using java #algorithms and data structures #java code examples #linked list in java #circular linked list

1600135200

## How to Install OpenJDK 11 on CentOS 8

### What is OpenJDK?

OpenJDk or Open Java Development Kit is a free, open-source framework of the Java Platform, Standard Edition (or Java SE). It contains the virtual machine, the Java Class Library, and the Java compiler. The difference between the Oracle OpenJDK and Oracle JDK is that OpenJDK is a source code reference point for the open-source model. Simultaneously, the Oracle JDK is a continuation or advanced model of the OpenJDK, which is not open source and requires a license to use.

#tutorials #alternatives #centos #centos 8 #configuration #dnf #frameworks #java #java development kit #java ee #java environment variables #java framework #java jdk #java jre #java platform #java sdk #java se #jdk #jre #open java development kit #open source #openjdk #openjdk 11 #openjdk 8 #openjdk runtime environment

1620466520

If you accumulate data on which you base your decision-making as an organization, you should probably think about your data architecture and possible best practices.

If you accumulate data on which you base your decision-making as an organization, you most probably need to think about your data architecture and consider possible best practices. Gaining a competitive edge, remaining customer-centric to the greatest extent possible, and streamlining processes to get on-the-button outcomes can all be traced back to an organization’s capacity to build a future-ready data architecture.

In what follows, we offer a short overview of the overarching capabilities of data architecture. These include user-centricity, elasticity, robustness, and the capacity to ensure the seamless flow of data at all times. Added to these are automation enablement, plus security and data governance considerations. These points from our checklist for what we perceive to be an anticipatory analytics ecosystem.

#big data #data science #big data analytics #data analysis #data architecture #data transformation #data platform #data strategy #cloud data platform #data acquisition

1622588700

## SKP's Algorithms and Data Structures #9: Java Problem: Monkeys in the Garden

In a garden, trees are arranged in a circular fashion with an equal distance between two adjacent trees. The height of trees may vary. Two monkeys live in that garden and they were very close to each other. One day they quarreled due to some misunderstanding. None of them were ready to leave the garden. But each one of them wants that if the other wants to meet him, it should take maximum possible time to reach him, given that they both live in the same garden.

The conditions are that a monkey cannot directly jump from one tree to another. There are 30 trees in the garden. If the height of a tree is H, a monkey can live at any height from 0 to H. Let’s say he lives at the height of K then it would take him K unit of time to climb down to the ground level. Similarly, if a monkey wants to climb up to K height it would again take K unit of time. The time to travel between two adjacent trees is 1 unit. A monkey can only travel in a circular fashion in the garden because there is a pond at the center of the garden.

So the question is where should two monkeys live such that the traveling time between them is maximum while choosing the shortest path between them in any direction clockwise or anti-clockwise. You have to answer only the maximum traveling time.

Input Format

The First Line consists of Total Number of Trees (N). Each of the Following N Lines contains the Height of Trees in a Clockwise Fashion.

Constraints

1 <= Total Trees <= 30

1 <= Height Of Trees(H) <= 10000

Output Format

You must Print an Integer which will be the Maximum Possible Travel Time.

[Explanation of the Solution]

Surprisingly, this Problem is under the Object-Oriented Programming (OOP) Section of the Problems! Initially, I was on the Lookout for a ‘Mathematically Superior’ Solution. But Couldn’t Reach Anywhere — In the End, I have a Simple Solution at O(n²). Iterate through Each ‘Combination of Trees’ and then Find the Clockwise and Anti-Clockwise Distance — At Each Iteration, the Minimum of the Two is Added to the Length of Each Tree. If this Value is Greater than the Maximum Path Length (Previous Iterations) — Replace the Maximum Path Length.

#algorithms #core java #data structures

1623399720

## SKP's Algorithms and Data Structures #5: Java Problem: Changes in Usernames

#### This Article Series Focuses on Algorithms, Data Structures, or Applying them to Problem Solving. In this Article, We Discuss the Solution to [Usernames Changes] Problem from Hacker Rank.

Algorithms/Data Structures — [Problem Solving]

There is a Specific Need for Changes in a List of Usernames. In a given List of Usernames — For Each Username — If the Username can be Modified and Moved Ahead in a Dictionary. The Allowed Modification is that Alphabets can change Positions in the Given Username.

Example

“Aba” can be Changed to only “Baa” — Hence, It can Never Find a Place Ahead in the Dictionary. Hence, Output will be “NO”. “Cat” can be Changed to “Act”, “Atc”, “Tca”, “Tac”, “Cta” and Definitely “Act” will Find a Place Before “Cat” in the Dictionary. Hence, Output will be “YES”.

[Function Description]

Complete the function possibleChanges in the Editor Below.

**_possibleChanges _**has the Following Parameters:

String usernames[n]: An Array of User Names

Returns String[n]: An Array with “YES” or “NO” Based on Feasibility

(Actual Question Says String Array, But Signature is List of Strings)

#algorithms #core java #data structures #problem solving #mathematical programming #java program #iq #complexity metrics #competitive #hacker rank