Algorithms

Primary tabs

No Description Set

Subjects: 

Bookmark to learn: Login to use bookmarks.

Bookmark to learn: Login to use bookmarks.

Add to collection ... add Algorithms to your collections:

Help using Flashcards ...just like in real life ;)

  1. Look at the card, do you know this one? Click to flip the card and check yourself.
  2. Mark card Right or Wrong, this card will be removed from the deck and your score kept.
  3. At any point you can Shuffle, Reveal cards and more via Deck controls.
  4. Continue to reveal the wrong cards until you have correctly answered the entire deck. Good job!
  5. Via the Actions button you can Shuffle, Unshuffle, Flip all Cards, Reset score, etc.
  6. Come back soon, we'll keep your score.
    “Repetition is the mother of all learning.”
  7. Signed in users can Create, Edit, Import, Export decks and more!.

Bookmark to learn: Login to use bookmarks.

Share via these services ...

Email this deck:

Right: #
Wrong: #
# Right & # Wrong of #

Minimum number of paranthesis to remove

1.create set to store indexes of elements to remove
2.Create stack, to balance out the paranthesis
3. push to stack if ( is encountered, pop if ) is encountered
4.If stack size = 0 and ) is encountered, add to indexes to remove
5. Finally add all the elements in stack to indexesToRemove

SubArray of contiguous subarray sum = K

1. Create HashMap with sum, count of number of times encountered
2. At an element, if sum-k is present, it means, there are some elements whose sum is K, in that case, increment result with that count of sum.
3.Finally return result

Next Permutation

1. Find the pair next to each other in non increasing order from last to 1st. call this startIndex
2. From startIndex, go till end of string, to find a number, just greater than this.endIndex
3. Swap startIndex number and endIndex
4. Reverse String from startIndex+1 to end of string

LCA of Btree Recursion

If node == null return,
if node == left or right, return node
leftLca =
rightLca =
if(leftLca = null) return right
if(rightLca = null) return left
return node;

Front image: 
Back image: 
Subjects: