Minimum cost to delete characters from String A to remove any subsequence as String B
Given two strings A and B of size N and M respectively, where B is a sub-sequence of A and an array arr[] of size N, where arr[i] is the cost to delete ith character from string A. The task is to find the minimum cost to delete characters from A such that after deletion no subsequence of A is the same as B....
read more
Walmart Labs Interview Experience | Set 3 (On-Campus)
Walmart Labs Interview Experience – On campus...
read more
Count all prime numbers that can be formed using digits of a given number
Given a string S consisting of N digits, the task is to find the number of distinct Prime Numbers that can be formed using the digits of the string S....
read more
Maximum Tip Calculator
Rahul and Ankit are the only two waiters in the Royal Restaurant. Today, the restaurant received N orders. The amount of tips may differ when handled by different waiters and given as arrays A[] and B[] such that if Rahul takes the ith Order, he would be tipped A[i] rupees, and if Ankit takes this order, the tip would be B[i] rupees....
read more
Longest path to the bottom of a Binary Tree forming an Arithmetic Progression
Given a Binary Tree consisting of N nodes, the task is to find the length of the longest path from any node to the bottom of the tree such that all the node values form an Arithmetic Progression....
read more
Maximum K-digit number possible from subsequences of two given arrays
Given two arrays arr1[] and arr2[] of length M and N consisting of digits [0, 9] representing two numbers and an integer K(K ? M + N), the task is to find the maximum K-digit number possible by selecting subsequences from the given arrays such that the relative order of the digits is the same as in the given array....
read more
Print Stack Elements from Top to Bottom
Given a Stack S, the task is to print the elements of the stack from top to bottom such that the elements are still present in the stack without their order being changed....
read more
Count substrings having frequency of a character exceeding that of another character in a string
Given a string S of size N consisting of characters a, b, and c only, the task is to find the number of substrings of the given string S such that the frequency of character a is greater than the frequency of character c....
read more
Queries for greatest pair sum in the given index range using Segment Tree
Given an array arr[] containing N integers and an array Q[] representing the range [L, R], the task is to find the greatest pair sum value in the range [L, R] where 0 ? L ? R ? N – 1. Examples:...
read more
Basic Operations on Binary Tree with Implementations
The tree is a hierarchical Data Structure. A binary tree is a tree that has at most two children. The node which is on the left of the Binary Tree is called “Left-Child” and the node which is the right is called “Right-Child”. Also, the smaller tree or the subtree in the left of the root node is called the “Left sub-tree” and that is on the right is called “Right sub-tree”....
read more
Count Subtrees that sum up to a given value X only using single Recursive Function
Given a binary tree containing n nodes. The problem is to count subtrees having the total node’s data sum equal to a given value using only single recursive functions....
read more
Maximizing Profits using Bitwise OR
Given two integers N, K and two integer arrays weights[] and profits[] each of size N where weights[i] is the weight associated with the ith item and profit[i] is the profit associated with the ith item. Maximize the profit by selecting a subset of items such that the bitwise OR of their weights is less than or equal to the given threshold K....
read more