Skip to content

techtrendings.com

Let's explore

Menu
Menu

Category: C++

Implement Trie Data Structure in C++- LeetCode

Posted on January 19, 2023January 19, 2023 by Avidlearner

A trie (pronounced as “try”) or prefix tree is a tree data structure used to efficiently store and retrieve keys in a dataset of strings. There are various applications of this data structure, such as autocomplete and spellchecker. Implement the Trie class: Input [“Trie”, “insert”, “search”, “search”, “startsWith”, “insert”, “search”] [[], [“apple”], [“apple”], [“app”], [“app”], [“app”], [“app”]] Output: [null,… Continue reading

C++ – Factory Design Pattern – Creation Design Pattern

Posted on January 18, 2023January 18, 2023 by Avidlearner

The Factory design pattern is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created. Here’s an example of how the Factory pattern might be implemented in C++: In this example, the Product class is an interface that… Continue reading

LFU Cache Implementation – LeetCode

Posted on January 18, 2023January 18, 2023 by Avidlearner

Design and implement a data structure for a Least Frequently Used (LFU) cache. Implement the LFUCache class: Example 1: Input [“LFUCache”, “put”, “put”, “get”, “put”, “get”, “get”, “put”, “get”, “get”, “get”] [[2], [1, 1], [2, 2], [1], [3, 3], [2], [3], [4, 4], [1], [3], [4]] Output [null, null, null, 1, null, -1, 3, null, -1, 3, 4] This… Continue reading

Program to find power of a number

Posted on November 11, 2022November 11, 2022 by Avidlearner

In computer programming, power is denoted by symbol ^ . To calculate the power y of a number x, we use x^y. For example Let’s say x = 2, y = 5 Output of x^y = 32. Below is the implementation of the same In the above program, the function pow() is used to calculate… Continue reading

Calling C++ function from C

Posted on November 10, 2022November 10, 2022 by Avidlearner

To Call a C++ function from C , you need to use extern “C” with the C++ function and call it from your C/C++ code. The extern “C” line tells the compiler that the external information sent to the linker should use C calling conventions and name mangling. Below is the implementation: This works only for non-member… Continue reading

Program to find roots of Quadratic Equation C++

Posted on November 9, 2022November 9, 2022 by Avidlearner

To find roots of Quadratic equation , we need to first calculate the determinant. Once the determinant is calculated then we will get the roots using the formula. Below is the program

Program to find best possible denomination of input money

Posted on November 9, 2022November 9, 2022 by Avidlearner

In this program, we will be finding possible denomination of money input from user. In this case we are assuming denomination as 1,5,10,25. For example if input money is 65 then denomination will be 25*2,10*1,5*1. Since we are trying to get best possible denomination such that we have least coins, so will store the denomination… Continue reading

Infix to Postfix Expression Using Stack

Posted on November 7, 2022 by Avidlearner

In this post, we will see infix to postfix expression.

Iterators and Ranges in C++

Posted on November 7, 2022November 7, 2022 by Avidlearner

An iterator is a variable that points to an element of a data structure. The iterator begin points to the first element of a data structure, and the iterator end points to the position after the last element. Let’s look at the example below Where vector v contain these elements: [4, 3, 2, 5, 6,… Continue reading

Maximum of all Subarrays of size K | LeetCode #239

Posted on August 5, 2022August 5, 2022 by Avidlearner

You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position. Return the max sliding window of size K Example 1: Input:… Continue reading

Posts navigation

  • 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