Code

My implementations for commonly asked questions in interviews. Method names are in italics. You can find the full implementation in this link https://github.com/kmdarshan/practice or you can refer to individual implementations as shown below.

  1. Reverse a string reverseString(str: String)
  2. Reverse string in place reverseStringInPlace
  3. Print two sum in a array printTwoSum
  4. Implement Queue using Stacks QueueUsingStacks
  5. Binary Search Tree And Check For Validity BST https://github.com/kmdarshan/practice/blob/master/binarySearchTree.swift
  6. Combine Two Sorted Arrays https://github.com/kmdarshan/practice/blob/master/combine_sorted_arrays.swift
  7. Print Common Numbers In Arrays printCommonNumbersIn
  8. Validate the brackets BracketValidator
  9. Get the maximum people living in a particular year GetMaximumYearPeopleLiving
  10. Adjacency graph / Graph Coloring Problem AdjacencyGraph graphColoringProblem
  11. Reverse Words in a Array https://github.com/kmdarshan/practice/blob/master/reverseWords.swift
  12. Graph Traversal (Breadth First Search and Depth First Search) https://github.com/kmdarshan/practice/blob/master/graph_with_dfs_bfs.swift
  13. Check if all permutations of the word is palindrome or not https://github.com/kmdarshan/practice/blob/master/check_palindrome.swift
  14. Implement a custom nsnotification center in swift https://redflowerinc.com/implementing-nsnotificationcenter-in-swift/
  15. Deleting a node from a binary search tree in swift https://github.com/kmdarshan/practice/blob/master/delete_from_a_binary_search_tree.swift
  16. Find if the binary tree is balanced https://github.com/kmdarshan/practice/blob/master/balanced_tree.swift
  17. Find if a string is permutation palindrome https://github.com/kmdarshan/practice/blob/master/permutation_palindrome.swift
  18. Find shortest path between two nodes in a graph https://github.com/kmdarshan/practice/blob/master/bfs_search_graph_find_minimum_distance.swift
  19. Dynamic Programming – Knapsack problem https://github.com/kmdarshan/practice/blob/master/knapsack.swift
  20. Second Largest Item in a binary search tree https://github.com/kmdarshan/practice/blob/master/second_largest_item_in_binary_search_tree.swift

More implementations are available here Gist