Fractional Knapsack
Problem Given two arrays, val[] and wt[] , representing the values and weights of items, and an integer capacity representing the maximum weight a knapsack can hold, determine the maximum total value
Search for a command to run...
Articles tagged with #algorithms
Problem Given two arrays, val[] and wt[] , representing the values and weights of items, and an integer capacity representing the maximum weight a knapsack can hold, determine the maximum total value
Problem Given an array, find the nearest smaller element G[i] for every element A[i] in the array such that the element has an index smaller than i. (link) More formally, G[i] for an element A[i] = an element A[j] such that j is maximum poss...

Problem statement You are given a sorted array ‘arr’ of length ‘n’, which contains positive integer positions of ‘n’ gas stations on the X-axis. You are also given an integer ‘k’. You have to place 'k' new gas stations on the X-axis. You can place th...

Problem Statement Given an array and a sum k, we need to print the length of the longest subarray that sums to k. (link) Note all elements are positive. Brute Force Approach To identify the longest subarray with a sum of k, we can systematically gene...

Merge sort approach

Selection, Bubble, Insertion, Merge, and Quick Sort
