Skip to content

techtrendings.com

Let's explore

Menu
Menu

Category: Algorithm

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

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

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

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;} };

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