Skip to content

This repo contains a collections of Algorithms and Data Structures questions which are usually asked for coding interviews. The implementation is done using Java.

License

Notifications You must be signed in to change notification settings

VinnieM/Popular-DS-Questions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Popular Data Structure and Algorithms.

This repo contains a collection of common Algorithms and Data Structures questions. The implementation is in Java. The questions mentioned below, or a variation of the questions are common for coding interviews. Most of the solutions have test cases which checks their validity. The time and space complexity for each solution is also mentioned.

Problems

Arrays

  1. Reverse an array without using extra space.
  2. Get the minimum and maximum element in an array.
  3. Find the Max and Second Max element in an array.
  4. Move negative elements to the left of the array.
  5. Rotate and array N number of times in O(n) time.
  6. Get the nth smallest element in an array in O(n) time.
  7. Sort an array which contains only 0, 1 and 2 in O(n) time and O(1) space.
  8. Merge 2 sorted arrays.
  9. Find the largest sub array in O(n) time.
  10. Find all duplicate numbers in an array.
  11. Find the duplicate number in an array of N + 1 integers.
  12. Merge 2 sorted arrays without using extra space.
  13. Kadanes Algorithm.
  14. Window Sliding.
  15. Given an array of integers of size ‘n’, calculate the maximum sum of ‘k’ consecutive elements in an array.
  16. Return the number of times a given pattern appears in a string.
  17. Minimum Deletions to Make Character Frequencies Unique.
  18. Three Number Sum
  19. Move Zero's to the left while preserving the order of elements.
  20. Smallest Difference. Given 2 non-empty arrays, find a pair of numbers who absolute difference is close to zero.
  21. Move a given element to the right side of the array.
  22. Urlify a given string without using extra space.
  23. Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target
  24. Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise.

Matrix

  1. Print the given matrix.
  2. Add 2 matrices.

Recursion

  1. Find the factorial of a number.
  2. Find the sum of the digits of a given number.
  3. Reverse a string.
  4. Check if a string is a palindrome.
  5. Find the subsequence of two strings
  6. Find all unique permutations in an array

Sorting

  1. Bubble Sort
  2. InsertionSort
  3. QuickSort
  4. MergeSort

Tree

  1. PreOrder Traversal
  2. InOrder Traversal
  3. PostOrder Traversal
  4. Breadth First Search
  5. Breadth First Search Each line
  6. Height of a Binary Tree
  7. Invert a Binary Tree

Contribute

If you find a bug, or a better way to implement, please raise a pull request.

About

This repo contains a collections of Algorithms and Data Structures questions which are usually asked for coding interviews. The implementation is done using Java.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages