# Category: Cracking The Coding Interview

## Find the in-order successor of a given node in a binary search tree

Note: We can do in-order traversal, which will give us a sorted array and then find the in-order successor very easily. But the time complexity of in-order traversal in O(n). Where as finding the...

## Queue using two stacks javascript

Problem : Implement queue’s enqueue and dequeue operations using two stacks. Logic: The queue is first-in-first-out and a stack is last in-first-out phenomena. Hence, the main difference between these two data structures is that...

## Determine if a binary tree is a binary search tree

Binary tree and Binary search tree are defined as follows : Binary tree is a tree data structure in which each node has at most two child nodes. A binary search tree (BST) is...

## Replace all spaces in a string with %20

The solution is self explanatory. Solution :

## Negate a number using addition operator

Problem: Given a number X, flip it to -X. Time complexity : O ( X ) Logic : The negation can be implemented by adding -1, X times. Solution :

## Given a singly linked list find if it is palindrome

Problem description : Write a function to determine if a singly linked list is a palindrome. Input : A linked list Output : Boolean (true or false) Approach 1: Reverse and compare the linked...

## Partition a linked list around a value

Problem description : Write code to partition a linked list around a value val, such that all nodes less than val come before all nodes greater than or equal to val. Input : A...

## Find the kth to last element of a singly linked list

Problem description : Implement a non-recursive algorithm to find the kth to last element of a singly linked list. Input : A linked list Output : A value of a node in a linked...

## Delete a node from a linked list in javascript

Problem description : Write a method to remove a node from a linked list. Input: A linked list Output: A linked list with one less node Logic : Iterate through the list, if you...

## Remove duplicates from an unsorted linked list

Problem description : Write a method to remove duplicates from an unsorted linked list. Input : A linked list Output : A linked list with unique elements This post is a follow-up of JavaScript...