DSA
Data Structures and Algorithms questions covering sorting, searching, and problem-solving techniques
7
Easy Questions
11
Medium Questions
4
Hard Questions
Easy Questions (7)
Write a function to check if a given string is a palindrome. Implement solutions for: (a) Case-sensitive, (b) Case-insensitive, (c) Ignoring spaces and special characters.
algorithmstringpalindromedarttwo-pointer
Write a function to generate the first N Fibonacci numbers. Implement both iterative and recursive solutions and explain the time complexity of each.
algorithmrecursioniterationdynamic-programmingfibonacci
Write a function to reverse a string in Dart. Implement at least 3 different approaches and compare their performance.
algorithmstringreversedarttwo-pointer
Write a function to remove all duplicate elements from a list, keeping only the first occurrence. Implement both approaches: (a) Preserving order, (b) Without preserving order.
algorithmsetduplicatesdartlist
Write a function to find both the maximum and minimum values in a list of integers in a single pass (without using built-in max/min functions).
algorithmlinear-searchoptimizationdartarray
Write a function to calculate the factorial of a number. Implement both recursive and iterative approaches. What is the maximum number for which factorial can be calculated in Dart?
algorithmrecursioniterationfactorialdart
Given a list of integers from 1 to 100, write functions to: (a) Return all even numbers, (b) Return all odd numbers, (c) Separate into two lists.
algorithmfilteringlistdartfunctional-programming
Medium Questions (11)
Write a function to find all duplicate elements in a list of integers. Return a list of unique duplicates (each duplicate should appear only once in the result).
algorithmhash-setduplicatesdartdata-structures
Given a list of integers and a target sum, write a function to find two numbers that add up to the target. Return their indices. If no such pair exists, return null.
algorithmhash-maptwo-sumdartarray
Write a function to rotate a list by K positions to the right. For example, [1,2,3,4,5] rotated by 2 becomes [4,5,1,2,3].
algorithmarrayrotationdartlist
Implement the Bubble Sort algorithm in Dart. Explain its time complexity in best, average, and worst cases. When would you use it in production?
algorithmsortingbubble-sortdarttime-complexity
Implement binary search algorithm in Dart. Include both iterative and recursive versions. What are the prerequisites for using binary search?
algorithmsearchingbinary-searchdartdivide-conquer
Given a sorted list and a target value, find the starting and ending position of the target. If not found, return [-1, -1]. Optimize for O(log n) time.
algorithmsearchingbinary-searchdartarray
Write a function to merge two sorted lists into one sorted list. Optimize for minimal space usage.
algorithmsortingmergetwo-pointerdart
Implement a Stack data structure in Dart with operations: push, pop, peek, isEmpty, and size. Use it to check if parentheses are balanced in an expression.
data-structurestacklifodartbalanced-parentheses
Implement a Queue data structure in Dart with operations: enqueue, dequeue, peek, isEmpty, and size. Demonstrate its use in a breadth-first search scenario.
data-structurequeuefifodartbfs
What will be the output of the following dart code? implements vs extends — difference between using it in class constructors and methods
dartoopsextendsimplementsinheritance
View Details →Code
How to remove the duplicate items in the list without using any built in methods like (contains, toSet(), where, indexOf) in flutter with some proper examples
dartdsalistduplicatesalgorithm
View Details →Code
Hard Questions (4)
Implement the Quick Sort algorithm in Dart. Explain the partitioning logic and time complexity. What is the worst-case scenario?
algorithmsortingquick-sortdivide-conquerdart
Explain how Dart's Map works internally. How does it handle collisions? What is the time complexity of get/set operations?
data-structurehash-maphash-tabledartcollision
Implement a singly linked list in Dart with operations: insert at beginning, insert at end, delete by value, and reverse the list.
data-structurelinked-listdartreversenode
Implement a binary tree in Dart and write functions for: (a) In-order traversal, (b) Pre-order traversal, (c) Post-order traversal, (d) Level-order traversal (BFS).
data-structurebinary-treetree-traversaldartdfs