Skip to content

Instantly share code, notes, and snippets.

@kodebinary
kodebinary / reverse-linked-list.cpp
Last active April 22, 2019 14:00
Reverse given linked list, full article can be found at https://kodebinary.com/reverse-given-linked-list
#include <iostream>
using namespace std;
struct Node
{
int data;
struct Node *next;
};
@kodebinary
kodebinary / circular-linked-list.cpp
Last active May 9, 2020 19:22
Circular Linked List, full article can be found at https://kodebinary.com/circular-linked-list
#include <iostream>
using namespace std;
struct Node
{
int data;
struct Node *next;
};
@kodebinary
kodebinary / find-loop-in-linked-list.cpp
Last active April 22, 2019 13:59
Find loop in a linked list, Full article can be found at https://kodebinary.com/find-loop-in-singly-linked-list
#include <iostream>
using namespace std;
struct Node
{
int data;
struct Node *next;
};
@kodebinary
kodebinary / stack.cpp
Last active April 22, 2019 13:58
Stacks, Full article can be found at https://kodebinary.com/stacks
#include <iostream>
using namespace std;
// Implemention of stack operations.
class Stack
{
private:
int *inp;
int cap;
@kodebinary
kodebinary / largest-histogram-area.cpp
Last active April 22, 2019 13:57
Largest rectangular area in a histogram, Full article can be found at https://kodebinary.com/largest-rectangular-area-in-a-histogram
#include <iostream>
#include <stack>
using namespace std;
// Function to find Largest Histogram Area.
int largestHistArea(int inp[], int len)
{
stack<int> stk;
int top, t;
#include <iostream>
using namespace std;
class Queue
{
protected:
int *que;
int rear, front, size;
int _cap;
@kodebinary
kodebinary / binary-tree.cpp
Last active April 22, 2019 13:55
Binary Tree, Full article with explanation can be found at https://kodebinary.com/binary-tree
#include <iostream>
using namespace std;
// Basic node for tree data structure
struct Node
{
int data;
// Left subtree
struct Node *left;
@kodebinary
kodebinary / check-binary-trees-identical.cpp
Last active April 22, 2019 13:50
Check given binary trees identical or not. Full solution with explanation is at https://kodebinary.com/find-given-two-binary-trees-are-identical
#include <iostream>
#include <stack>
using namespace std;
struct Node
{
int data;
struct Node *left;
struct Node *right;
@kodebinary
kodebinary / length-of-binary-tree.cpp
Last active April 22, 2019 13:48
Find length of given binary tree. Explanation can be found in https://kodebinary.com/find-height-of-given-binary-tree
#include <iostream>
using namespace std;
struct Node
{
int data;
struct Node *left;
struct Node *right;
};
@kodebinary
kodebinary / level-order-traversal.cpp
Last active April 22, 2019 13:47
Level order traversal of given binary tree. Explanation can be found here at https://kodebinary.com/level-order-traversal
#include <iostream>
#include <queue>
using namespace std;
struct Node
{
int data;
struct Node *left;
struct Node *right;