/GeekforGeeks

Welcome to the Code Challenges repository! Here, you'll find a collection of diverse coding challenges solved in various programming languages. Whether you're a beginner looking to sharpen your skills or an experienced developer aiming to explore new problem-solving approaches.

Primary LanguageJava

1:Array Pair Sum Divisibility Problem

Given an array of integers nums and a number k, write a function that returns true if given array can be divided into pairs such that sum of every pair is divisible by k.

Example: nums = [9, 5, 7, 3] k = 6 Output: True Explanation: {(9, 3), (5, 7)} is a possible solution. 9 + 3 = 12 is divisible by 6 and 7 + 5 = 12 is also divisible by 6.

---------------------------------------------------------------

2:Reverse First K elements of Queue

Given an integer K and a queue of integers, we need to reverse the order of the first K elements of the queue, leaving the other elements in the same relative order.

Only following standard operations are allowed on queue.

->enqueue(x) : Add an item x to rear of queue ->equeue() : Remove an item from front of queue ->size() : Returns number of elements in queue. ->front() : Finds front item.

Note
: The above operations represent the general processings. In-built functions of the respective languages can be used to solve the problem.

Example: 5 3 1 2 3 4 5 Output: 3 2 1 4 5 Explanation: After reversing the given input from the 3rd position the resultant output will be 3 2 1 4 5.

---------------------------------------------------------------

3:Insertion Sort for Singly Linked List

Given a singly linked list, sort the list (in ascending order) using insertion sort algorithm..

Example: Input: N = 10 Linked List = 30->23->28->30->11->14-> 19->16->21->25 Output : 11 14 16 19 21 23 25 28 30 30 Explanation : The resultant linked list is sorted.

---------------------------------------------------------------

4:Find duplicate rows in a binary matrix

Given a boolean matrix of size RxC where each cell contains either 0 or 1, find the row numbers (0-based) of row which already exists or are repeated.

Example: nput: R = 2, C = 2 matrix[][] = {{1, 0}, {1, 0}} Output: 1 Explanation: Row 1 is duplicate of Row 0.

---------------------------------------------------------------

5:Leaders in an array

Given an array A of positive integers. Your task is to find the leaders in the array. An element of array is a leader if it is greater than or equal to all the elements to its right side. The rightmost element is always a leader.

Example: Input n = 6 A[] = {16,17,4,3,5,2} Output: 17 5 2 Explanation: The first leader is 17 as it is greater than all the elements to its right. Similarly, the next leader is 5. The right most element is always a leader so it is also included.

---------------------------------------------------------------

Zero Sum Subarray

You are given an array arr[] of size n. Find the total count of sub-arrays having their sum equal to 0.

Example:

Input: n = 6 arr[] = {0,0,5,5,0,0} Output: 6 Explanation: The 6 subarrays are [0], [0], [0], [0], [0,0], and [0,0].