ProDeveloperTutorial.com

Tutorials and Programming Solutions
Menu
  • Shell Scripting
  • System Design
  • Linux System Programming
  • 4g LTE
  • Coding questions
  • C
  • C++
  • DSA
  • GIT
  • 450 DSA Cracker
  • 5G NR
  • O-RAN
Given a sorted array, find the starting and ending index that matches the target – 2 solutions using C++

Given a sorted array, find the starting and ending index that matches the target – 2 solutions using C++

Given a sorted array and an element “k”. Get the start index and the end index of the given “k” value. Example 1: Array: K = 4 Output: Example 2: Array: K = 10 Output: We can solve this problem by 2 methods. Method 1: By …
Full Article
No Comments
Given an array, check if it has any duplicate elements, 2 solutions in CPP

Given an array, check if it has any duplicate elements, 2 solutions in CPP

If the array has duplicates output should be true, else return false if all the array elements are unique. Example: Input: Output: True Input: Output: False   Method 1: By using set. As we know that, set contains only unique elements. Hence we insert all the …
Full Article
No Comments
Given a string, reverse all the vowels in the string , solution in C++

Given a string, reverse all the vowels in the string , solution in C++

Example 1: Input: hello Output: holle Example 2: Input: prodevelopertutorial Output: pradivolupertotereol We can solve this problem in 2 methods.   Method 1: By using STL functions. In this method we use “find_first_of” and “find_last_of” find_first_of(“characters_to_search_for”, start_from_index) : It will return the position of the first …
Full Article
No Comments
Given an array and a number n, rotate the array by n steps to its right solution in C++

Given an array and a number n, rotate the array by n steps to its right solution in C++

Example: Array = {1, 2, 3, 4, 5 ,6, 7}; n = 4 Output: Explanation: rotate 1 steps to the right: rotate 2 steps to the right: rotate 3 steps to the right: rotate 4 steps to the right: This problem can be solved in 2 …
Full Article
No Comments
Create a data structure for n elements and constant operations

Create a data structure for n elements and constant operations

The complexity of the operations should be as follows: * Insertion of an element – O(1) * Deletion of an element – O(1) * Finding an element – O(1)   According to question, we need to insert, delete and find the element in constant time. This …
Full Article
No Comments
Given a linked list, sort the list using insertion sort. Solution with explanation

Given a linked list, sort the list using insertion sort. Solution with explanation

Example: Input: 4->2->1->3 Output: 1->2->3->4 Insertion sort is a comparison based sorting algorithm. In this algorithm we divide the list into 2 parts. The left most part is sorted part, and the right most part is unsorted part. In insertion sort, after each pass at least …
Full Article
No Comments
Reorder list in to alternate nodes like first lowest and first highest. Solution in C++

Reorder list in to alternate nodes like first lowest and first highest. Solution in C++

Given a singly linked list L: L0→L1→…→Ln-1→Ln, reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… Example 1: Given 1->2->3->4, reorder it to 1->4->2->3.   The  algorithm will works as shown below: Step 1: Find the middle of the list. Step 2: Reverse the second half of the list. Step 3: …
Full Article
No Comments
Given a sentence and maxWidth. Arrange the text in such a way that each line has exactly maxWidth characters, solution in C++

Given a sentence and maxWidth. Arrange the text in such a way that each line has exactly maxWidth characters, solution in C++

Example: Input: words = maxWidth = 16 Output: This question can be divided into 2 different parts. In the first part, we need to check how many words can be fit into a single line. In the second part, determine the space to be inserted between …
Full Article
No Comments
Given a linked list, if it has a cycle, get the node where the cycle begins else return NULL.

Given a linked list, if it has a cycle, get the node where the cycle begins else return NULL.

In the previous question, we wanted to know if there is a cycle. But in this question we want to know the node from where the cycle begins. For example: 1 -> 2  -> 3  ->4  ->3 Entrance of the cycle is 3.   The steps …
Full Article
No Comments
Given a linked list, check if it has a cycle in it, solution in C++

Given a linked list, check if it has a cycle in it, solution in C++

Solution Explanation: Take an extra pointer “fast” and assign its starting point to head. Every iteration moves the “fast” pointer 2 steps forward and “head” pointer 1 step forward. At certain point, if there is a cycle, both “head” and “fast” pointer will meet at the …
Full Article
No Comments

Posts navigation

Prev 1 … 68 69 70 71 72 73 74 … 81 Next
  • Shell Scripting
  • System Design
  • Linux System Programming
  • 4g LTE
  • Coding questions
  • C
  • C++
  • DSA
  • GIT
  • 450 DSA Cracker
  • 5G NR
  • O-RAN

ProDeveloperTutorial.com

Tutorials and Programming Solutions
Copyright © 2022 ProDeveloperTutorial.com