Java icon indicating copy to clipboard operation
Java copied to clipboard

feat: Add `MinStackUsingTwoStacks` new algorithm with Junit tests

Open Hardvan opened this issue 1 year ago • 3 comments

  • [x] I have read CONTRIBUTING.md.
  • [x] This pull request is all my own work -- I have not plagiarized it.
  • [x] All filenames are in PascalCase.
  • [x] All functions and variable names follow Java naming conventions.
  • [x] All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • [x] All new code is formatted with clang-format -i --style=file path/to/your/file.java

Hardvan avatar Oct 13 '24 07:10 Hardvan

Codecov Report

Attention: Patch coverage is 84.61538% with 2 lines in your changes missing coverage. Please review.

Project coverage is 63.98%. Comparing base (6682c7c) to head (cdc4952).

Files with missing lines Patch % Lines
...m/thealgorithms/stacks/MinStackUsingTwoStacks.java 84.61% 1 Missing and 1 partial :warning:
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #5758      +/-   ##
============================================
+ Coverage     63.96%   63.98%   +0.01%     
- Complexity     4172     4178       +6     
============================================
  Files           583      584       +1     
  Lines         16320    16333      +13     
  Branches       3150     3151       +1     
============================================
+ Hits          10439    10450      +11     
- Misses         5456     5457       +1     
- Partials        425      426       +1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov-commenter avatar Oct 13 '24 07:10 codecov-commenter

This contribution looks like from leetcode. And according to rules, could you please provide any sources that describe that this is not from leetcode or similar resources.

alxkm avatar Oct 13 '24 15:10 alxkm

The MinStackUsingTwoStacks algorithm is a widely known solution in data structures, frequently discussed in programming interviews and textbooks. It is not exclusive to LeetCode but is a classic problem in designing a stack that supports push(), pop(), and retrieving the minimum element in constant time using two stacks—one to store the elements and the other to track the minimum values. You can find similar implementations and discussions on several well-known platforms, such as GeeksforGeeks and Stack Overflow, as well as in books like Cracking the Coding Interview.

This problem is a common way to assess problem-solving skills and understanding of space-time trade-offs in interviews and is thus not tied to any single platform.

Hardvan avatar Oct 14 '24 02:10 Hardvan