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
Author: Avidlearner
Program to find best possible denomination of input money
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
In this post, we will see infix to postfix expression.
Iterators and Ranges in C++
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
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
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
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
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
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
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