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  string s and a dictionary wordDict containing a list of non-empty words, determine if s can be seperated into a space-separated sequence of one or more dictionary words. Solution in C++

Given a string s and a dictionary wordDict containing a list of non-empty words, determine if s can be seperated into a space-separated sequence of one or more dictionary words. Solution in C++

Example 1: Input: s = "applepenapple", wordDict = Output: true Explanation: "applepenapple" can be seperated as "apple pen apple". This problem can be solved by using DP .   We shall have a look at the code, before explaining the code.   Solution in C++ #include<iostream> …
Full Article
No Comments
Given a linked list such that each node contains an additional random pointer which could point to any node in the list or null. Return the deep copy of  the list, solution in C++

Given a linked list such that each node contains an additional random pointer which could point to any node in the list or null. Return the deep copy of the list, solution in C++

This problem can be solved by 2 ways: Using HashMap Using O(n) time and Constant Space O(1) We shall discuss both of the solutions here.   Using HashMap We take 2 loops. In the first loop we copy the data into our new list. In the …
Full Article
No Comments
Given an array every element appears three times except for one. Find that single one. Solution in C++

Given an array every element appears three times except for one. Find that single one. Solution in C++

Example 1: Input: Output: 3 We can solve this by 2 methods: unordered_map XOR operation. The solution for “unordered_map” is same as the solution for “single-number”. Below explains in details about the solution using BIT Manipulation. If the problem were this: “one element appears once, all …
Full Article
No Comments
Solve Sudoku, explanation in CPP

Solve Sudoku, explanation in CPP

Write a program to solve a Sudoku puzzle by filling the empty cells. A sudoku solution must satisfy all of the following rules: Each of the digits 1-9 must occur exactly once in each row. Each of the digits 1-9 must occur exactly once in each column. Each of the the digits 1-9 must …
Full Article
No Comments
Check if there is a gas stations along a circular route, solution with explanation in CPP

Check if there is a gas stations along a circular route, solution with explanation in CPP

There are N gas stations along a circular route, where the amount of gas at station i is gas. You have a motorcycle with an unlimited gas tank and it costs cost of gas to travel from station i to its next station (i+1). You begin …
Full Article
No Comments
Given a 2D board with X and O, get all the region surrounded by X, explanation in CPP

Given a 2D board with X and O, get all the region surrounded by X, explanation in CPP

Input: X X X X X O O X X X O X X O X X Output: X X X X X X X X X X X X X O X X We can solve this problem in 2 ways: BFS DFS In this …
Full Article
No Comments
Given a string return all the substring that is a palindrome, solution in CPP

Given a string return all the substring that is a palindrome, solution in CPP

Example: Input: "aab" Output: , ] The solution for this problem can be done with the help of DFS. The logic is to loop through the string one by one. Once we find a palindromic string for the string str(0, i) we store the current string …
Full Article
No Comments
Given a non-empty array, all the elements appears twice except for one, find that element.

Given a non-empty array, all the elements appears twice except for one, find that element.

Example 1: Input: Output: 1 We can solve this by 2 methods: unordered_map XOR operation. We shall discuss both of the solutions in this tutorial. Solution using unordered_map. Use unordered_map, increment the “second” in unordered_map when ever you get an element. At the end, iterate throughout …
Full Article
No Comments
Word Ladder explanation with solution in CPP

Word Ladder explanation with solution in CPP

Given a begin_word and end_word, find the words that transforms from begin_word to end_word. Example 1: Input: beginWord = "hit", endWord = "cog", wordList = Output: 5 Explanation: As one shortest transformation is "hit" -> "hot" -> "dot" -> "dog" -> "cog", return its length 5. …
Full Article
No Comments
Optimum Time to Buy and Sell Stock for maximum profit explanation with solution in C++

Optimum Time to Buy and Sell Stock for maximum profit explanation with solution in C++

Example 1: Input: Output: 5 Explanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5. Not 7-1 = 6, as selling price needs to be larger than buying price. The solution for this problem is …
Full Article
No Comments

Posts navigation

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