Find element occuring once when all other are present thrice
Given an array of integers arr[] of length N, every element appears thrice except for one which occurs once.
Find that element which occurs once.
Find element occuring once when all other are present thrice
Given an array of integers arr[] of length N, every element appears thrice except for one which occurs once.
Find that element which occurs once.
Given an unsigned integer N. The task is to swap all odd bits with even bits. For example, if the given number is 23 (00010111), it should be converted to 43(00101011). Here, every even position bit is swapped with adjacent bit on the right side(even position bits are highlighted in the binary representation of 23), and every odd position bit is swapped with an adjacent on the left side.
A number is called faithful if you can write it as the sum of distinct powers of 7.
e.g., 2457 = 7 + 72 + 74 . If we order all the faithful numbers, we get the sequence 1 = 70, 7 = 71, 8 = 70 + 71, 49 = 72, 50 = 70 + 72 . . . and so on.
Given some value of N, you have to find the N’th faithful number.
Maximum XOR of two numbers in an array
Given an array of non-negative integers of size N. Find the maximum possible XOR between two numbers present in the array.
Given an array arr[] of size, N. Find the subarray with maximum XOR. A subarray is a contiguous part of the array.
2277. Closest Node to Path in Tree
You are given a positive integer n representing the number of nodes in a tree, numbered from 0 to n - 1 (inclusive). You are also given a 2D integer array edges of length n - 1, where edges[i] = [node1i, node2i] denotes that there is a bidirectional edge connecting node1i and node2i in the tree.
You are given a 0-indexed integer array query of length m where query[i] = [starti, endi, nodei] means that for the ith query, you are tasked with finding the node on the path from starti to endi that is closest to nodei.
Return an integer array answer of length m, where answer[i] is the answer to the ith query.
Given two integers n and r, find nCr. Since the answer may be very large, calculate the answer modulo 109+7
Given two numbers L and R (inclusive) find the product of primes within this range. Print the product modulo 109+7. If there are no primes in that range you must print 1.
Given a number n, find the total numbers, less than or equal to n which have at-least one common factor with n other than 1.