Solve Me First The purpose of this challenge is to familiarize you with reading input from stdin (the standard input stream) and writing output to stdout (the standard output stream) using our environment. Review the code provided in the editor below, then complete the solveMeFirst function so that it returns the sum of two integers read from stdin. Take some time to understand this code so you’re prepared to write it yourself in future challenges. Select a language below, and …

Home

#### Blog Posts

Designer PDF Viewer When you select a contiguous block of text in a PDF viewer, the selection is highlighted with a blue rectangle. In a new kind of PDF viewer, the selection of each word is independent of the other words; this means that each rectangular selection area forms independently around each highlighted word. For example: Designer PDF Viewer In this type of PDF viewer, the width of the rectangular selection area is equal to the number of letters in …

Java Subarray A subarray of an n-element array is an array composed from a contiguous block of the original array’s elements. For example, if array=[1,2,3], then the subarrays are [1],[2],[3],[1,2],[2,3] and [1,2,3]. Something like [1,3] would not be a subarray as it’s not a contiguous subsection of the original array. The sum of an array is the total sum of its elements. An array’s sum is negative if the total sum of its elements is negative. An array’s sum is …

Jumping on the Clouds Hackerrank Emma is playing a new mobile game involving n clouds numbered from 0 to n-1. A player initially starts out on cloud c0, and they must jump to cloud cn-1. In each step, she can jump from any cloud i to cloud i+1 or cloud i+2. There are two types of clouds, ordinary clouds and thunderclouds. The game ends if Emma jumps onto a thundercloud, but if she reaches the last cloud (i.e., cn-1), she …

Simple Array Sum Given an array of N integers, can you find the sum of its elements? Input Format The first line contains an integer, N, denoting the size of the array. The second line contains N space-separated integers representing the array’s elements. Output Format Print the sum of the array’s elements as a single integer. Sample Input 6 1 2 3 4 10 11 Sample Output 31 Explanation We print the sum of the array’s elements, which is: . …

In computer science, tree traversal (also known as tree search) is a form of graph traversal and refers to the process of visiting (checking and/or updating) each node in a tree data structure, exactly once.Here we are talking about Pre-order tree traversal, and we will also learn a problem of hackerrank related to it.

Minimum Distances Hackerrank Consider an array of integers, A=[a0,a1,….,an-1]. The distance between two indices, i and j, is denoted by di,j=|i-j|. Given A, find the minimum di,j such that ai=aj and i!=j. In other words, find the minimum distance between any pair of equal elements in the array. If no such value exists, print -1. Note: |a| denotes the absolute value of a. Input Format The first line contains an integer, n, denoting the size of array A. The second …