ProDeveloperTutorial.com

608 FOLLOWERS

Tutorials and Programming Solutions. Competitive programing related articles that are easy to understand.

ProDeveloperTutorial.com

1y ago

Problem Statement:
You are given an arrya of repeating elements. You need to find and print the majority element.
An element that appears more tha n/2 times, is called as majority element.
Example
Input : {3, 3, 4, 2, 4, 4, 2, 4, 4}
Output : 4
4 is repeated 5 times that is greater than the half of the size of the array.
Solution
Method 1: Brute Force Approach
Create 2 loops, and then keep track of the maximum count for all the different elements.
If the count become greater than n/2 times break the loop and return the element.
Method 2: Using hash map
A hashmap is a key value pair. H ..read more

ProDeveloperTutorial.com

1y ago

Problem Statement:
Given an unsorted array, check if it is palindrome array or not.
Example:
arr[] = {1, 2, 0, 2, 1}
Output: Palindrome
Solution:
The solution is very simple, below are the steps to be follow:
1. We take 2 pointer, first pointer will point to beginning of the array, second pointer will point to the end of the array
2. Then we check if both of the elements are same, if they are same then we increment the first pointer and decrement the second pointer. And repeat Step 1 and 2.
3. We repeat the steps till we reach the mid of the array.
4. If they are not same, then we bre ..read more

ProDeveloperTutorial.com

1y ago

Problem Statement:
Given an unsorted array, you need to find 3 elements whose sum is the minimum.
Example:
arr = {-1, 2, 3, -2};
Output: -1
The elements are: -1, -2, 2
The solution in very simple, take 3 variables that will hold minimum, second minimum and third minimum element present in the array and print the sum of these three elements.
Solution in C++
#include <vector>
#include <algorithm>
//visit www.ProDeveloperTutorial.com for 450+ solved questions
#include <iostream>
#include <queue>
using namespace std;
void get_min_sum(int a ..read more

ProDeveloperTutorial.com

1y ago

Problem Statement:
You are given with 2 sorted arrays, you need to merge the array in-place.
You may assume that the first array will have enough space to accomodate all the array elements.
Example:
Input:
arr1 = [1,2,3]
arr2 = [2,5,6]
Output: [1,2,2,3,5,6]
According to the question, we can assume that the first array will have enough space to hold total (m+n) array elements.
So arr1 = [1, 2, 3, 0, 0, 0]
The solution to this problem is very simple, below are the steps on how to do it.
We will have to do a reverse sorting, by taking the max element from arr2 and comparing with t ..read more

ProDeveloperTutorial.com

1y ago

Problem Statement:
You are given an array, you need to check if there are 3 consecutive odds exist. If exist then return true else false.
Example
Input: arr = [2,6,4,1]
Output: false
Solution
The solution is very simple.
Just iterate throught the array and check if the element is odd, then increment the odd variable.
If the element is not odd, then reset the odd variable to 0.
At the end check if odd variable is equal to 3 and get the result
Solution in C++
#include <algorithm>
//visit www.ProDeveloperTutorial.com for 450+ solved questions
#include <iostream>
#inc ..read more

ProDeveloperTutorial.com

1y ago

Problem Statement:
You are given an array, you need to check if a number and its double exist in that array.
Example
Input arr = {10, 2, 5, 3}
Output: True
N = 5 M = 10. 5*2 = 10. So there exist 2 integers, such that the integer and its double exist.
Solution
In this solution, we will use hash map.
At every index, we check for 2 cases:
Case 1: If we find the double of the element in the map, then we return true. This is for odd numbers
Case 2: We divide the current element by 2 and find if the arr[i]/2 element is present then we return true. This is for even numbers.
else we just ins ..read more

ProDeveloperTutorial.com

1y ago

Problem Statement:
You are given an integer n. You need to return the integers that sum upto 0.
Example
Input: n = 5
Output: {-5, -1, 1, 2, 3}
Solution
Method 1:
In this method, we will use the numbers from 1, 2, .. n-1 and then negation.
Method 2:
Consider the cases below
n = 1, [0]
n = 2, [-1, 1]
n = 3, [-2, 0, 2]
n = 4, [-3, -1, 1, 3]
n = 5, [-4, -2, 0, 2, 4]
So we can derive mathematical formula as : A[i] = i * 2 - n + 1
Solution in C++
#include <algorithm>
//visit www.ProDeveloperTutorial.com for 450+ solved questions
#include <iostream> ..read more

ProDeveloperTutorial.com

1y ago

Problem Statement:
You are given an array of integers.
You need to return the count of the numbers that has even number of digits.
Example
Input arr = {12, 123, 1234, 12345, 123456}
Output: 3
The numbers {12, 1234, 123456} has even digits.
Solution
The solution is very simple.
Convert the number into string and then take the size of the string.
Then take modulo of the size with 2. If it is 0, then it is even and increment the count.
#include <algorithm>
//visit www.ProDeveloperTutorial.com for 450+ solved questions
#include <iostream>
#include <s ..read more

ProDeveloperTutorial.com

2y ago

In this chapter we shall see which RRC messages can be sent:
1. RRC messages can be sent Unprotected prior to AS security activation.
2. RRC messages can be sent Unprotected after AS security activation.
3. RRC messages that never be sent unprotected by gNB or UE
4. RRC Message can never be sent after AS security activation
5. RRC Messages that can be sent without integrity protection after AS security activation.
1. RRC messages can be sent Unprotected prior to AS security activation. <
MIB
SIB1
SystemInformation
Paging
RRCReconfiguration *
RRCReconfigurationComplete *
RRCReject
RRCRelease ..read more

ProDeveloperTutorial.com

2y ago

A single Central Unit can be connected to multiple Distributed Units.
CU-CP will have RRC, PDCP
CU-UP will have SDAP, PDCP
Distributed Units will include RLC, MAC, H-PHY.
F1 interface is used to cinnect between DU and CU.
eCPRI is connected to H-PHY and L-PHY.
CPRI is connected to L-PHY and RF, i.e between BBU and RRU.
Need for separation of gNB-CU and gNB-DU
To accommodate new age requirements, RAN must be towards functional splits.
The functionality of RAN will be distributed between DU and CU in 5G.
Separating existing RAN will reduce the bandwidth requirement.
Different ways to segment CU ..read more