DSA curriculum
DSA practice
Short exercises. Try them first, open the hint if you are stuck, and the solution last.
Exercise 1
Reverse with a stack
Use an array as a stack to reverse the string "queue" and print the result.
Your solutionJavaScriptExercise 2
First duplicate
Write firstDuplicate(arr) that returns the first value seen twice, or -1. Use a Set so it is O(n).
Your solutionJavaScriptExercise 3
Balanced brackets
Write isBalanced(s) for strings of ( and ). Return true when every ( is closed.
Your solutionJavaScript