In this problem, we are given coordinates of three points that lie on a page. Our task is to find if it’s possible to rotate the page by an angle or not. The rotation of the page is made in such a way that the new position of ‘x’ is the old position of ‘y’, the new position of ‘y’ is the old position of ‘z’. And print “Yes” or “No” based on the rotation.Let’s take an example to understand the problem, Input: x = (0, 1), y = (1, 0), z = (0, -1)Output: YesExplanation:We can rotate the page by 90o.Solution Approach: We ... Read More
In this problem, we are given an array arr of sorted unique values. Our task is to find if array has an element whose value is half of array sum. Problem Description: For the array arr[], we need to find element x in the array such that the sum of all elements of array is equal to 2*X.Let’s take an example to understand the problem, Input: arr[] = {2, 4, 5, 6, 7}Output: NoExplanation: Sum = 2 + 4 + 5 + 6 + 7 = 24No element found.Solution Approach: To solve the problem, we simply need to find the elements which is half of the ... Read More
In this problem, we are given two strings str and corStr. Our task is to find if a string starts and ends with another given string. Let’s take an example to understand the problem, Input: str = “abcprogrammingabc” conStr = “abc”Output: TrueSolution Approach: To solve the problem, we need to check if the string starts and ends with the conStr. For this, we will find the length of string and corStr. Then we will check if len(String) > len(conStr), if not return false.Check if prefix and suffix of size corStr are equal and check they contain corStr or not.Program to illustrate the working of ... Read More
In this problem, we are given a list of n numbers and a number. Our task is to find if a number is divisible by every number in a list. We need to check if the given number divides all elements of the list or not.Let’s take an example to understand the problem, Input: list[] = [4, 10 ,6, 5, 9] num = 5Output: NoExplanation:Elements 4, 6, 9 are not divisible by 5.Solution Approach: To solve the problem, we need to check if any element of the list is divisible by num. If every number of lists is divisible by num, return true else ... Read More
File handling in programming languages is very important for the interaction of programming with the memory for accessing files and fetching data in it.Using a program, you can read data from a file as well as write data to the file and do a lot more functions.Here, we will see reading of data from a file.In programming, before performing any operation you need to open the file. And there are multiple modes to open a file in the programming language. The access to the file is based on the mode it is opened with.Here we will learn about the difference between ... Read More
In this problem, we are given an array arr[] of size n that denotes a tree. Our task is to find height of Binary Tree represented by Parent array. A Binary Search Tree (BST) is a tree in which all the nodes follow the below-mentioned properties −The value of the key of the left sub-tree is less than the value of its parent (root) node's key.The value of the key of the right subtree is greater than or equal to the value of its parent (root) node's key.Height of a tree is the number of nodes traversed when going from root node ... Read More
Fermat’s little theorem −This theorem states that for any prime number p, Ap - p is a multiple of p.This statement in modular arithmetic is denoted as, ap ≡ a (mod p)If a is not divisible by p then, ap - 1 ≡ 1 (mod p)In this problem, we are given two numbers a and p. Our task is to verify fermat’s little theorem on these values.We need to check if ap ≡ a (mod p) or ap - 1 ≡ 1 (mod p)Holds true for the given values of a and p.Let’s take ... Read More
p>File globbing also known as Path Name Expansion. It is the method of recognizing wildcard patterns in linux and then finding the file path expansion based on these patterns.Wildcard Patterns are strings that are used for selection of multiple files based on patterns.The character patterns like “?” , “[ ]” , “*” are used for pattern matching and multiselection of the files.Example of wildcard characters using in file globbing:Asterisk (*) : the * pattern is used when we need to match 0 or more character after the string in the filename.For example: file* will match all files with name file, files, file2, or with anything ... Read More
In this problem, we are given a number N. Our task is to find the floor value of the fifth root of a number.Fifth Root of a number is the number which when multiplied to itself 5 times returns the number.If N1/5 = a then, a*a*a*a*a = N.Let’s take an example to understand the problem, Input: N = 325Output: 3Explanation: The fifth root of 325 is 3.179 whose floor value is 3.Solution Approach: A simple solution to the problem is traversing from 1 to n. And finding the number which when multiplied to itself five times gives the number.Here, the exact value cannot be found ... Read More
In this problem, we are given an array arr consisting of n elements that are either 0 or 1. Our task is to fill array with 1’s using minimum iterations of filling neighbors. Let’s take an example to understand the problem, Input: arr[] = {0, 1, 1, 0, 0, 1}Output: 1Solution Approach −To solve the problem, we need to know the fact that if 1 is present in a position it can convert two neighbouring 0’s to 1.If, arr[i] is 1.Then, arr[i-1] and arr[i+1] will be converted to 1.Using this, the ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP