AlgoGenesis / C

AlgoGenesis is a centralized open-source platform dedicated to providing optimized and well-documented algorithm implementations in C. Perfect for both beginners and advanced users, this repository serves as a comprehensive learning resource for solving algorithmic challenges.
MIT License
90 stars 306 forks source link

[NEW ALGORITHM] : Frog Jump #1827

Closed ananydev closed 2 days ago

ananydev commented 3 days ago

Issue will be closed if:

1) You mention more than one algorithm. You can create a separate issue for each algorithm once the current one is completed.
2) You propose an algorithm that is already present or has been mentioned in a previous issue.
3) You create a new issue without completing your previous issue.

Note: These actions will be taken seriously. Failure to follow the guidelines may result in the immediate closure of your issue.


Name: Frog Jump

[NEW ALGORITHM]

About:

Propose a new algorithm to be added to the repository Geek wants to climb from the 0th stair to the (n-1)th stair. At a time the Geek can climb either one or two steps. A height[N] array is also given. Whenever the geek jumps from stair i to stair j, the energy consumed in the jump is abs(height[i]- height[j]), where abs() means the absolute difference. return the minimum energy that can be used by the Geek to jump from stair 0 to stair N-1.

Example:

Input: n = 4, height = {10 20 30 10} Output: 20 Explanation: Geek jump from 1st to 2nd stair(|20-10| = 10 energy lost). Then a jump from the 2nd to the last stair(|10-20| = 10 energy lost). So, total energy lost is 20 which is the minimum. Expected Time Complexity: O(n) Expected Space Complexity: O(n)


Labels:

new algorithm, gssoc-ext, hacktoberfest, level1


Assignees:

ananydev commented 3 days ago

@pankaj-bind kindly assign me asap as it's last day to contribute