Skip to content

krishnadevz/no-of-ways-to-score-in-game-in-cplusplus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

no-of-ways-to-score-game-in-cplusplus


time complexity is O(n) because of loop the incrementation of loop depends on the value of n Consider a game where a player can score 3 or 5 or 10 points in a move. Given a total score n, find number of ways to reach the given score.

Have look on the upcoming example after that you can get that

Example Input: n = 20 Output: 4 There are following 4 ways to reach 20 (10, 10) (5, 5, 10) (5, 5, 5, 5) (3, 3, 3, 3, 3, 5)

Input: n = 13 Output: 2 There are following 2 ways to reach 13 (3, 5, 5) (3, 10)

The idea is to create a table of size n+1 to store counts of all scores from 0 to n. For every possible move (3, 5 and 10), increment values in table. answer is calculated using table (0to13) by using loops this is all hope you done Thank you Stay Tuned

Author

And changes in code by pull request

About

No description or website provided.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages