Compute the least cost path in a weighted digraph using BFS
Consider a directed graph where the weight of its edges can be one of x, 2x, or 3x (x is a given integer), compute the least-cost path from source to destination efficiently.
Ace your Coding Interview
Get hired by top tech companies with our comprehensive interview preparation.
Get StartedConsider a directed graph where the weight of its edges can be one of x, 2x, or 3x (x is a given integer), compute the least-cost path from source to destination efficiently.
In the k–partition problem, we need to partition an array of positive integers into k disjoint subsets that all have an equal sum, and they completely cover the set.
Given a set S of positive integers, determine if it can be partitioned into three disjoint subsets that all have the same sum, and they cover S.
In this post, we will see how to list out all permutations of a string in Python.
Given a binary tree, write a recursive algorithm to print all paths from leaf to root node.
Given a positive integer n, find all n–digit binary numbers having more 1’s than 0’s for any prefix of the number.
Given a linear equation of k variables, count the total number of possible solutions to it. The problem is similar to finding the total number of ways to get the denomination of coins. Here, coefficients of an equation can be considered coins denominations, and the RHS of an equation can be considered the desired change.
Given a binary tree, write an efficient algorithm to invert it.
Given an array representing a min-heap, convert it into a max-heap. The conversion should be done in-place and in linear time.
Given a BST and a positive number k, find the k’th smallest node in it.
Given an array, reverse every group of consecutive m elements in a given subarray of it.
Given an integer array, find all distinct combinations of a given length k. The program should print only distinct combinations.