/algorithmic-puzzles

Various Brainteasing Algorithms

Primary LanguageJava

Various Brainteasing Algorithms

Bitwise

  • Power of 2
  • Next Power of 2
  • Power of 3
  • Power of 4
  • Count 1's in a binary representation of a number (several ways)
  • Find an array element that appears once among others that appear twice
  • Find an array element that appears twice among others that appear once

Arrays

  • Prints out 2D array in a spiral order
  • Generates 2D array in a spiral order (both inwards and out)
  • Rotate 2D array 90 degrees (clockwise and counter-clockwise
  • Binary search in sorted array
  • Binary search in 2D sorted array
  • All character permutations in an array
  • Find an array element that appears twice among others that appear once
  • Concat N arrays into one, while keeping character order

Strings

  • Segregate even/odd numeric characters in a string
  • Reverse word characters
  • Reverse word vowels
  • Reverse sentence words, while keeping the characters in the correct order
  • All character permutations in a string
  • All word permutations in a sentence
  • Check if two strings are anagrams
  • Check if two strings are isomorphic
  • Regex parser
  • Valid palindrome
  • Check if string is numeric (ambiguous problem statement)

Trees

  • Create a balanced binary tree
  • Count leaf nodes in a tree
  • Find min depth of a tree
  • Find max depth of a tree
  • Invert a binary tree
  • Are two trees are the same

Math

  • Find missing number in array of numbers
  • Raise number to a power
  • Test for prime

Linguistic chains

A Java program that finds the word from which one can remove the most letters, one at a time, such that each resulting word is itself a valid word