Skip to content

Instantly share code, notes, and snippets.

View anubhavbagri's full-sized avatar
🎯
Focusing

Anubhav Bagri anubhavbagri

🎯
Focusing
View GitHub Profile

Process Tree

A hypothetical chain of processes is represented as a tree. Processes are numbered starting at 1, incremented by 1. Every process spawns a number of processes equal to its process number. The first node, processNumber 1, spawns 1 process, the second spawns 2 and so on. Given a process number, find the process number of its parent.

Example

processNumber = 6

From the diagram, the parent of 6 is 3.

graph TD

REST API: Relevant Food Outlets

A REST API contains information about food outlets across multiple cities. Given the city name and the maximum cost for 2 persons, use the API to get the list of food outlets in this city and have an estimated cost less than or equal to the given cost. The API returns paginated data.

To access the information, perform an HTTP GET request to https://jsonmock.hackerrank.com/api/food_outlets? city=&page= where is the city to get the food outlets for, and is an integer that denotes the page of the results to return.

For example, a GET request to https://jsonmock.hackerrank.com/api/food_outlets?city=Seattle&page=2 returns data associated with the second page of results for Seattle.

Similarly, a GET request to https://jsonmock.hackerrank.com/api/food_outlets?city-Houston&page=1 returns the first page of results for Houston.

@anubhavbagri
anubhavbagri / ParallelSearch.java
Last active May 13, 2021 14:55
A multithreaded java program where 4 threads are used to execute parallel search on large number of integers read from a text file and reduce the overall search time.
import java.util.*;
import java.io.IOException;
import java.nio.file.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
public class ParallelSearch implements Runnable {
private int startIndex, endIndex;
private static int nElements, key;