Category: geeksforgeeks

Showing 13 posts in category "geeksforgeeks"

Subset Sum Problem from Geeks for Geeks

Here is an explanation of the Dynamic Programming solution for the Subset Sum Problem. Given an array of non-negative integers and a target sum, we need to check if there exists a subset whose elements sum up exactly to...

Parenthesis Checker

Given a string s, composed of different combinations of '(' , ')', '{', '}', '[', ']', verify the validity of the arrangement.An input string is valid if:          1. Open brackets must be cl...

Stock Span

The stock span problem is a financial problem where we have a series of daily price quotes for a stock and we need to calculate the span of stock price for all days. The span arr[i] of the stocks price on a gi...

k largest elements

Given an array arr[] of positive integers and an integer k, Your task is to return k largest elements in decreasing order.  Examples: Input: arr[] = [12, 5, 787, 1, 23], k = 2 Output:...

in order traversal

In-order traversal is one of the standard depth-first traversals for binary trees. The order of visiting nodes in an in-order traversal is: Left subtree $ ightarrow$ Root $ ightarrow$ Right subtree. Recursive Impleme...

Subarrays with sum K

Given an unsorted array of integers, find the number of continuous subarrays having sum exactly equal to a given number k. Examples: Input: arr = [10, 2, -2, -20, 10], k = -10 Output: 3 Explaination: Subarray...

Set Matrix Zeros

class Solution { public: void setMatrixZeroes(vector<vector<int>> &mat) { int n = mat.size(); int m = mat[0].size(); bool firstRowHasZero = false; bool firstColHa...

Search Sorted Matrix Solution in C++

In this post, we explore a C++ solution to search for a value in a row-column sorted matrix. The matrix is sorted such that each row is sorted in ascending order from left to right, and the first element of any row is g...

 Find Minimum in Rotated Sorted Array

https://leetcode.com/problems/find-minimum-in-rotated-sorted-array Suppose an array of length n sorted in ascending order is rotated between 1 and n times. For example, the a...

Non Repeating Character

Difficulty: EasyAccuracy: 40.43%Submissions: 262K+Points: 2 Given a string s consisting of lowercase Latin Letters. Return the first non-repeating character in s. If there is no non-repeating...

Find the Peek Element in the Array

Peak element https://www.geeksforgeeks.org/problems/peak-elementhttps://leetcode.com/problems/find-peak-elementDifficulty: BasicAccuracy: 38.86%Submissions: 510K+Points: 1 Given an array arr[] where no t...

Insert New Interval and Merge Overlapping Intervals

Given an array of non-overlapping intervals intervals where intervals[i] = [starti, endi] represent the start and the end of the ith event and intervals is sorted in ascendin...

WordPress Function Reference

I've spent some time on their site trying to understand how to retrieve the current category, and you know what, its not really working for me.You would think that the most popular CMS on the internet would have better d...