[Geeks for Geeks] Find element occuring once when all other are present thrice

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.

Read more
[Geeks for Geeks] Swap all odd and even bits

Swap all odd and even bits

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.

Read more
[Geeks for Geeks] Faithful Numbers

Faithful Numbers

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.

Read more
[Geeks for Geeks] Maximum XOR of two numbers in an array

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.

Read more
[Geeks for Geeks] Maximum XOR subarray

Maximum XOR subarray

Given an array arr[] of size, N. Find the subarray with maximum XOR. A subarray is a contiguous part of the array.

Read more
[LeetCode] Closest Node to Path in Tree

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.

Read more
[Geeks for Geeks] nCr

nCr

Given two integers n and r, find nCr. Since the answer may be very large, calculate the answer modulo 109+7

Read more
[Geeks for Geeks] Product of Primes

Product of Primes

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.

Read more
[Geeks for Geeks] Mathematical manipulation

Mathematical manipulation

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.

Read more
[AlgoExpert] Spin RingsRead more