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
You are given a positive number “n”, print the sequence of grey code solution in CPP

You are given a positive number “n”, print the sequence of grey code solution in CPP

  Example 1: Input: 2 Output:  Explanation: 00 - 0 01 - 1 11 - 3 10 - 2 Before solving this problem, let us understand what grey code is. Before knowing about grey code, we shall understand about the binary format. Below are some numbers and …
Full Article
No Comments
You are given a linked list and a key “x”, partition the list in such a way that, all the nodes less than “x” comes before the nodes greater than or equal to “x” solution in CPP

You are given a linked list and a key “x”, partition the list in such a way that, all the nodes less than “x” comes before the nodes greater than or equal to “x” solution in CPP

Example: Input: head = 1->4->3->2->5->2, x = 3 Output: 1->2->2->4->3->5 Solution: Let us understand the question first. The question has 2 parts: Part 1: Here we need to partition the list in such a way that the nodes less than “x” should come to left and …
Full Article
No Comments
Given a linked list with duplicates, remove the nodes with duplicates and keep only distinct numbers, with solution in CPP

Given a linked list with duplicates, remove the nodes with duplicates and keep only distinct numbers, with solution in CPP

  Example 1: Input: 1->2->3->3->4->4->5 Output: 1->2->5 Solution: For the solution, we take 2 nodes a “dummy” node and a “current” node. Use “dummy” node, in case if the head is needed to be deleted. “current” node is used to iterate throughout the list. So in …
Full Article
No Comments
you are given an sorted array with repeated elements that is rotated at some point, return true or false if you find the key element in C++

you are given an sorted array with repeated elements that is rotated at some point, return true or false if you find the key element in C++

Example 1: Input: nums = , key = 0 Output: true Before solving this problem, please look at the similar problem. Search in Rotated Sorted Array. We achieve this by below 2 lines: while (low < high && array == array) low++; // skip duplicates from …
Full Article
No Comments
Given a sorted array, remove duplicate elements in-place in CPP

Given a sorted array, remove duplicate elements in-place in CPP

Each element can appear only once or twice. Example 1: Given nums = The function should return 6, because . As each element can appear only twice. The solution is simple. We shall 2 variables, one will hold the new length and other is used to …
Full Article
No Comments
N-Queens in CPP

N-Queens in CPP

This problem is to place n number of queens on a chessboard such that, no two queens attack each other. Return all the solutions.   Example: Input: 4 Output: , ] Introduction: A queen in a chess board can move it her left, right and diagonal. …
Full Article
No Comments
Given 2D matrix and a word, find if the word exists in the grid in C++

Given 2D matrix and a word, find if the word exists in the grid in C++

Given a 2D matrix and some words, return true of the letters are constructed with the combination cells that are horizontally or vertically adjacent to each other. Example: Matrix = , , ] Given word = "ABCCED", return true. Given word = "ABCD", return false. This …
Full Article
No Comments
Given a set of distinct integers, nums, return all possible subsets in CPP

Given a set of distinct integers, nums, return all possible subsets in CPP

Note: The solution set must not contain duplicate subsets. Example: Input: nums = Output: ,   ,   ,   ,   ,   ,   ,   ] The problem can be solved in 2 ways: Iterative Backtracking   Solution 1: Iterative Solution. In this solution, …
Full Article
No Comments
Given two integers n and k, return all possible combinations of k numbers out of 1 … n in CPP

Given two integers n and k, return all possible combinations of k numbers out of 1 … n in CPP

Example: Input: n = 4, k = 2 Output: , , , , , , ] This problem can be solved in 2 ways. Iterative Recursion/Backtrack Solution 1: Iterative approach: In the iterative solution, we take a temp array of size “k”. Then we move to the …
Full Article
No Comments
Given an array with element  colored red, white or blue, sort them in-place, with the colors in the order red, white and blue in CPP

Given an array with element colored red, white or blue, sort them in-place, with the colors in the order red, white and blue in CPP

We represent color red, white, and blue with integers 0, 1, and 2 to represent respectively. Example: Input: Output: We can solve this by many different ways. Solution 1 will be counting all the number of 0’s, 1’s and 2’s. Then insert those number of elements …
Full Article
No Comments

Posts navigation

Prev 1 … 71 72 73 74 75 76 77 … 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