Skip to content

techtrendings.com

Let's explore

Menu
Menu

Category: C++

Binary Tree Level Order Traversal

Posted on June 24, 2022June 24, 2022 by Avidlearner

Given the root of a binary tree, return the level order traversal of its nodes’ values. (i.e., from left to right, level by level). Example: Input: root = [3,9,20,null,null,15,7] Output: [[3],[9,20],[15,7]] Input: root = [1] Output: [[1]] Algorithm: Since we have to traverse the tree level wise and need to process node from left to right, we can… Continue reading

Print Odd Even in Separate threads in C++| TechTrendings

Posted on May 24, 2022May 24, 2022 by Avidlearner

This is a popular question asked for experience programmer while testing multithreading knowledge. We can do it in two ways. Approach 1: Using lock mechanism Approach 2: Using Condition variable

Program to move all zeroes to the end

Posted on March 27, 2022March 27, 2022 by Avidlearner

Given an integer array nums, move all 0’s to the end of it while maintaining the relative order of the non-zero elements. Note that you must do this in-place without making a copy of the array. Example 1: Input: nums = [0,1,0,3,12]Output: [1,3,12,0,0]Example 2: Input: nums = [0]Output: [0]

Program to reverse word in a string

Posted on March 27, 2022March 27, 2022 by Avidlearner

Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: s = “Let’s take LeetCode contest”Output: “s’teL ekat edoCteeL tsetnoc”Example 2: Input: s = “God Ding”Output: “doG gniD” Solution: string reverseWords(string s) {int n = s.length();if(n==0){return s;} };

Find the length of longest substring without repeating characters|techtrendings

Posted on March 27, 2022March 27, 2022 by Avidlearner

Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = “abcabcbb”Output: 3Explanation: The answer is “abc”, with the length of 3.Example 2: Input: s = “bbbbb”Output: 1Explanation: The answer is “b”, with the length of 1.Example 3: Input: s = “pwwkew”Output: 3Explanation: The answer is “wke”,… Continue reading

Program to find unpaired element in an Array in C++|Leetcode |techtrendings

Posted on February 20, 2022February 20, 2022 by Avidlearner

A non-empty array A consisting of N integers is given. The array contains an odd number of elements, and each element of the array can be paired with another element that has the same value, except for one element that is left unpaired. For example, in array A such that: A[0] = 9 A[1] =… Continue reading

Program to Rotate an Array in C++|LeetCode |techtrendings

Posted on February 20, 2022February 20, 2022 by Avidlearner

An array A consisting of N integers is given. Rotation of the array means that each element is shifted right by one index, and the last element of the array is moved to the first place. For example, the rotation of array A = [3, 8, 9, 7, 6] is [6, 3, 8, 9, 7]… Continue reading

Custom Deleters in C++

Posted on January 28, 2022January 28, 2022 by Avidlearner

In this tutorial, we will learn how to create a custom deleted to delete a smart pointer in C++. Introduction to Custom Deleter in C++ When a smart pointer of any user-defined type is destroyed, the destructor of the class is invoked giving us the ability to explicitly inspect and modify the delete process. But… Continue reading

Copy Constructor vs Assignment Operator in C++

Posted on January 23, 2022January 23, 2022 by Avidlearner

The Assignment Operator is when you replace the data with an already existing(previously initialized) object withsome other object’s data. Lets see an example: You can see here I call the assignment operator when I already initialized the Assign object. Then later I assign foo2 tofoo . All the changes to appear when you call that… Continue reading

marsexploration in C++ Hackerank

Posted on January 21, 2022January 21, 2022 by Avidlearner

A space explorer’s ship crashed on Mars! They send a series of SOS messages to Earth for help. Letters in some of the SOS messages are altered by cosmic radiation during transmission. Given the signal received by Earth as a string, , determine how many letters of the SOS message have been changed by radiation.… Continue reading

Posts navigation

  • Previous
  • 1
  • 2
  • 3
  • Next

Recent Posts

  • Implement Trie Data Structure in C++- LeetCode
  • How TLS Works
  • C++ – Factory Design Pattern – Creation Design Pattern
  • C++ – Strategy Design Pattern – Behavioral Design Pattern
  • LFU Cache Implementation – LeetCode

Recent Comments

  • automatically like friends photos on instagram on Program to find unpaired element in an Array in C++|Leetcode |techtrendings
  • Twicsy on Program to find unpaired element in an Array in C++|Leetcode |techtrendings

Archives

  • January 2023
  • November 2022
  • August 2022
  • June 2022
  • May 2022
  • March 2022
  • February 2022
  • January 2022

Categories

  • Algorithm
  • Algorithm
  • C++
  • Design Patterns
  • Multithreading
  • OS Concepts
  • Programming
  • Uncategorized

Meta

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Join Our Mailing List for the Latest News and Updates.

© 2023 techtrendings.com | Powered by Superbs Personal Blog theme