Skip to main content

Questions tagged [greedy]

A greedy algorithm is an algorithm that follows the problem solving heuristic of making the locally optimal choice at each stage with the hope of finding a global optimum.

greedy
-1 votes
0 answers
11 views

Minimum Platform Problem, basically aim it to find max no of overlaps

Given arrival and departure times of all trains that reach a railway station. Find the minimum number of platforms required for the railway station so that no train is kept waiting. Consider that all ...
Vaibhav Verma's user avatar
1 vote
0 answers
101 views

Is there a simple way of sorting a vector based on 2 others without losing the original index of the elements in C++?

Given an array of elements, I've got two arrays that contain data identifying each element. For example, element number k is identified by the value contained in position k of both of the arrays. ...
areksuu's user avatar
  • 85
0 votes
0 answers
11 views

DynamicProgramming Proble,

Problem Link :https://www.geeksforgeeks.org/problems/count-numbers-containing-43022/1 Problem Description : You are given a number n, Return the count of total numbers from 1 to n containing 4 as a ...
LOKESH's user avatar
  • 1
5 votes
4 answers
273 views

Reduce the sum of differences between adjacent array elements

I came across a coding challenge on the internet the question is listed below: Have the function FoodDistribution(arr) read the array of numbers stored in arr which will represent the hunger level of ...
Mohd Alomar's user avatar
1 vote
1 answer
235 views

fusing inner lists within list function to return highest possible integer dynamic programming

new to programming and currently trying to challenge myself and learn dynamic programming. I have this question to implement a function that takes an array and outputs the 'highest cuteness' of the ...
romynichols's user avatar
0 votes
0 answers
34 views

Is gradient descent a greedy algorithm?

Gradient/steepest descent iteratively makes locally optimal decisions to minimize a function. At each iteration, it adjusts the parameters in the direction that minimizes the function the most, based ...
Rubem Pacelli's user avatar
0 votes
1 answer
166 views

Example where the greedy approach fails for minimum vertex cover problem

A greedy algorithm to find a vertex cover for a given graph would be to greedily select the vertex with the maximum degree and add it to the vertex cover set. Remove the node and all its edges from ...
NITHIN SABU's user avatar
0 votes
0 answers
16 views

How do i slice an array into m groups and minimize the sum of elements of largest slice? [duplicate]

I want to slice an array into m groups and minimize the sum of elements of largest slice while respecting to the order of elements in array. For example: elements: 13.85 22.15 11.84 7.85 12.15 11.09 m:...
wwyyaa's user avatar
  • 195
0 votes
1 answer
47 views

Optimizing Product Allocation to Baskets

I am currently facing a challenge in devising an algorithm that optimally solves the following task: We have a set of products, each associated with specific baskets they can be placed into. For ...
Cookie's user avatar
  • 27
0 votes
0 answers
42 views

Assign visually distinct colors to graphs with undirected edges

Given a graph G with V nodes and V different colors, I would like to assign colors to these nodes such that the color assigned to a node is as visually distinct as it can get from all of its neighbors....
Anirudh Mukherjee's user avatar
0 votes
3 answers
196 views

Finding the maximum concatenate number from the list of numbers provided

Problem Statement : Input Format : First line of the input contains an integer n. Second line of inputs contains the n array elements Output format : The largest number that can be composed using all ...
Siddhanta Mallick's user avatar
0 votes
0 answers
35 views

Time complexity of Rectangle Covering algorithm

I have a task to submit on greedy algorithms. I wrote this code but I'm not sure what the time complexity of the algorithm is. This problem called "Rectangle Covering". This is the code: ...
MeiRR's user avatar
  • 1
0 votes
0 answers
24 views

Can't solve optimization problem using greedy algorithm

I encountered a problem during a company's online assessment a few months ago and I'm still struggling to solve it. The problem involves optimizing the purchase of items over a certain number of days ...
Chia-Sheng Lin's user avatar
1 vote
2 answers
103 views

Why is the program NOT stuck in an infinite loop?

Noob question here. I've just started to learn programming, and I've taken the cs50 course. I've done the first 3 problems from the problem set 1 in C, but I don't understand why in my 3rd program, ...
VestoSlypher's user avatar
1 vote
1 answer
162 views

Minimum Time to Perform One Task of Each Category (with Different Release Times)

I've recently taken an OA in which you needed to write an algorithm for finding the earliest time at which you were able to complete one task from each category. Each task has a duration and a time at ...
psygo's user avatar
  • 6,883

15 30 50 per page
1
2 3 4 5
70