DSA question set · 29 questions
Getting Started with DSA Practice and Code Visualization
Build DSA basics with counting, loops, functions, and small numerical problems. Run examples and trace your own solutions in DSAWiser’s code visualizer.
Start with the smaller skills
This collection is a starting point for Basic coding practice. Work on reading inputs, writing loops, calling functions, and returning the expected result before combining those skills into a larger DSA problem.
The production collection starts with printing numbers, repeating a word, and summing natural numbers. Problems such as factorial, powers, and counting digits then give you more practice with stopping conditions and changing state. Use the question list below as the source of the collection’s current contents.
Before you start
You need a little familiarity with your chosen language: variables, comparisons, function arguments, and output. If one of those still feels uncertain, use a small input in the visualizer to see what changes after each statement.
You do not need to know hash maps, dynamic programming, or a catalog of interview patterns to begin here.
A practical way to solve each question
- Read what the function must return. Distinguish returning a value from printing it.
- Write the expected result for a small input by hand. Check the smallest valid input too.
- Describe each step in plain words, then translate those steps into code.
- Run the examples. For counting and loops, check the first and last iteration carefully.
- Step through the solution and compare each variable with your prediction. Use a breakpoint just before a step you want to inspect.
Check the stopping condition
Many small mistakes come from doing one iteration too many, starting at the wrong number, or returning before the work is complete. Before running your solution, predict how many times the loop or recursive function should execute.
When you move on to a larger collection, keep the same habit: state the result you want, choose a small example, and inspect the intermediate steps. The related Two Sum walkthrough shows how this approach extends to a different problem; it is further reading, not a question in this collection.
Questions in this set
29 totalOpen a question in the editor to read its statement and examples. Sign in to practice.
- Print Numbers from 1 to NRecursion · MathBasic
- Print Numbers from N Down to 1Recursion · MathBasic
- Print a Word N TimesRecursionBasic
- Sum of First N Natural NumbersRecursion · MathBasic
- Factorial of a NumberRecursion · MathBasic
- Power of a Number (aᵇ)Recursion · MathBasic
- Count Digits of a NumberRecursion · MathBasic
- Sum of Digits of a NumberRecursion · MathBasic
- Product of Digits of a NumberRecursion · MathBasic
- Greatest Common Divisor (GCD)Recursion · MathBasic
- N-th Fibonacci NumberRecursion · MathBasic
- Check Power of TwoRecursion · MathBasic
- Sum of Array ElementsRecursion · ArraysBasic
- Find Maximum Element in an ArrayRecursion · ArraysBasic
- Find Minimum Element in an ArrayRecursion · ArraysBasic
- Linear Search in an ArrayRecursion · ArraysBasic
- Count Occurrences in an ArrayRecursion · ArraysBasic
- Find First Index of an ElementRecursion · ArraysBasic
- Count Even Numbers in an ArrayRecursion · ArraysBasic
- Check if Array is SortedRecursion · ArraysBasic
- Length of a StringRecursion · StringsBasic
- Count Vowels in a StringRecursion · StringsBasic
- Count Occurrences of a CharacterRecursion · StringsBasic
- Check if String is a PalindromeRecursion · StringsBasic
- Reverse a StringRecursion · StringsBasic
- Remove All Occurrences of a CharacterRecursion · StringsBasic
- Replace Character in a StringRecursion · StringsBasic
- Count Steps to Reduce to ZeroRecursion · MathBasic
- Check if All Elements are PositiveRecursion · ArraysBasic