Showing posts from March, 2021

Consecutive elements

Level MEDIUM You are given an array arr of N non-negative integers, you need to return true if the array elements consist of consecutive numbers otherwise return false. For Example: If the given array is [4,3,5] then you should return true as all the array elements are in consecutive order. Input Format: The first line of input contains a single integer T, representing the number of test cases or queries to be run. Then the T test cases follow. The first line of each test case contains an integer 'N', representing the length of the array. The next line contains 'N' single space-separated integers representing elements of the array. Output Format : For each test case, print “True” or “False” in a separate line. Note: You are not required to print the expected output, it has already been taken care of. Just implement the function. Constraints: 1 <= T <= 10 1 <= N <= 10^5 0 <= arr[i] <= 10^9 Time Limit: 1 sec Sample Input 1: 1 4 1 2 4 6 Sample Output

Division of 4

Level EASY Given an array, update each element of the array by the value obtained by dividing the element by 4 (take only integer part). If the value obtained by dividing the element by 4 comes out to be 0, then update the element with value -1. Note: Do not return or print the array and make changes in the same array. Input Format : Line 1: An Integer N i.e. size of the array Line 2: N integers which are elements of the array, separated by spaces Output Format : N elements of the array, separated by space Constraints : 1 <= N <= 10^5 0 <= array[i] <= 100 Time Limit: 1 sec Sample Input : 2 3 8 Sample Output : -1 2 Sample Output Explanation : The input list is [ 3, 8 ] , after dividing each element by 4, our list becomes [ 0, 2 ] . So as the first element is 0 so replace it by -1.

Delete node

You have been given a linked list of integers. Your task is to write a function that deletes a node from a given position, 'pos'. Note : Assume that the Indexing for the linked list always starts from 0. If the position is greater than or equal to the length of the linked list, you should return the same linked list without any change. Illustration : The following images depict how the deletion has been performed. Image-I : Image-II : Input format : The first line contains an Integer 't' which denotes the number of test cases or queries to be run. Then the test cases follow. The first line of each test case or query contains the elements of the linked list separated by a single space. The second line of each test case contains the integer value of 'pos'. It denotes the position in the linked list from where the node has to be deleted.  Remember/Consider : While specifying the list elements for input, -1 indicates the end of the singly linked list and hence,

How to setup an Nginx reverse proxy with a SSL certificate in XWIKI

Hey everyone,  Tonight I continue my previous post of the complete setup of xwiki. This post is about how to setup  Nginx as a reverse proxy with an SSL certificate. Before moving further we consider that xwiki runs on the server( EC2 server) with a domain name called To create a custom domain name using AWS you can follow this link:- By default, Tomcat 9 works on port 8080 , and you can only visit your XWiki site from the same port. If you want to facilitate visitors' access by removing the port number part, you can install Nginx as a reverse proxy between XWiki and visitors. Step 1, Install Nginx using apt: sudo apt install nginx -y Step 2, Setup Nginx as a reverse proxy by modifying its default site configurations: cd /etc/nginx/sites-available  sudo mv default default.bak  sudo vi default Step 3, Edit the file server {  listen;  proxy_request_buffering off;  proxy_buffering off;  location / { 

Popular posts from this blog

How to pass parameters in webhook?

Access and modify all the resources of our Wiki.js using WikiJS API

Fahrenheit to Celsius