Posts

Showing posts from July, 2020

Git Commands Cheet Sheet

This guide includes an introduction to Git, a glossary of terms and lists of commonly used Git commands. What is Git? 🤔 Git gives each developer their own repository containing the entire history of changes. More formally Git is a fast, scalable, distributed revision control system with an unusually rich command set that provides both high-level operations and full access to internals. Before you get started with Git, you need to understand some important terms:😀 Commit:-  It   represents a specific point in your project's history. Checkout:-  Checkout command to switch between branches. Fetch:-  Fetch command copies and downloads all of a branch's files to your device.   Fork:-  A fork is a copy of a repository. Take a copy of the project for doing some changes without affecting your main project. Head:-  It represents the most current commit of the repository you're currently working in. The commit at the top of a branch is called th...

New position

Level  EASY You are given two integers n and k. Assume numbers from 1 to n are arranged in a way that - all odd numbers (in ascending order) comes first and then comes to all even numbers (also in ascending order). You need to find and return the integer which is at position k (numbering of positions start from 1). Input Format : Line 1 : Integer n Line 2 : Integer k Output Format : Integer at position k Constraints : 1 <= k <= n <= 10^12 Sample Input: 7 4 Sample Output: 7 Sample Output Explanation : Numbers from 1 to 7 are arranged as - (1, 3, 5, 7, 2, 4, 6) and number at position 4 is 7. So, the output is 7.

Check Even Partitioning

Level  EASY Given a number n, check whether the number can be the sum of two even numbers or not. Return true if it can be, return false otherwise. Constraints : ** 1 <= n <= 100000** Input Format : Integer n Output Format : YES or NO Sample Input 1 : 8 Sample Output 1 : YES Sample Input 2 : 9 Sample Output2 : NO

Factorial

Level  EASY Given an integer n, find and print the factorial of the given integer. Constraints : 0 <= n <1000 Input Format : Integer n Output Format : Print answer Sample Input 1: 6 Sample Output 1: 720 Sample Input 2: 4 Sample Output 2: 24

LCM^k

Given three integers   N,M,K  and array of integers   a 1 ,a 2 ,...,a n . Find the value of   LCM (a 1 k ,a 2 k ,...,a n k )   mod   M , where   LCM   means   Least Common Multiple . Input The first line of the input contains a single integer   T   denoting the number of test cases(1 ≤  T   ≤ 10).  The description of   T   test cases follows. First line contains three positive integers   N, M, K (1 ≤   N  ≤ 3 * 10 5 , 1 ≤   M ,   K  ≤ 10 9 ). The second line contains   N   space-separated integers   a 1 ,a 2 ,...,a n .(1 ≤ a i   ≤ 10 6 ,1 ≤   i   ≤   N ). Output For each test case print the value of   LCM (a 1 k ,a 2 k ,...,a n k )   mod   M . SAMPLE INPUT   1 5 20 3 17 2 9 4 12 SAMPLE OUTPUT   8 Explanation In the test LCM(17 3 ,2 3 ,9 3 ,4 3 ,12 3 ) = 229220928, 229220928 mod 20 = 8. Note...

Cutting a material

You are given a disk-shaped or circular material. Determine the maximum number of pieces in which the material can be cut into by using exactly  N  straight cuts. You must perform the task for   T   tasks separately. Input format The first line contains   T   denoting the number of test cases. Next   T   lines contain a single integer   N . Output format Print   T   separate lines each containing answer for each test case. Note :   Use a 64-bit variable to store and read all the variables. Constraints 1 ≤ T ≤ 10 5 0 ≤ N ≤ 10 8 SAMPLE INPUT   2 0 4 SAMPLE OUTPUT   1 11 Explanation For the first case where N = 0, using 0 cuts you can get a maximum of 1 piece of the material. For the second case where N = 4, using exactly 4 straight cuts you can get 11 pieces of material.

Love Triangle

Two boys,   Venky   and   Sagar , are at war over a girl,   Riu . Driven by their feelings, they decided to confess to   Riu . Since both of them were equally dumb,   Riu   decided that she would go out with that boy who would successfully find the pattern and thus prove that he is less dumb. Read input until end of file. Given :   0<=N<=10^18 SAMPLE INPUT   1 2 3 10 100 SAMPLE OUTPUT   1 2 3 11 121

C. Make It Good

C. Make It Good time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output You are given an array   𝑎 a   consisting of   𝑛   integers. You have to find the length of the smallest (shortest)   prefix   of elements you need to erase from   𝑎 a   to make it a   good   array. Recall that the prefix of the array   𝑎 = [ 𝑎 1 , 𝑎 2 , … , 𝑎 𝑛 ]   is a subarray consisting several first elements: the prefix of the array   𝑎 a   of length   𝑘 k   is the array   [ 𝑎 1 , 𝑎 2 , … , 𝑎 𝑘 ] ( 0 ≤ 𝑘 ≤ 𝑛 0 ≤ k ≤ n ). The array   𝑏 b   of length   𝑚 m   is called   good , if you can obtain a   non-decreasing   array   𝑐 ( 𝑐 1 ≤ 𝑐 2 ≤ ⋯ ≤ 𝑐 𝑚 ) from it, repeating the following operation   𝑚   times (initially,   𝑐   is empty): select either the first or the last element of   𝑏 , remov...

Popular posts from this blog

MySQL Multi Source Master Slave Replication using GTID

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

How to pass parameters in webhook?