Skip to content

Instantly share code, notes, and snippets.

View reyou's full-sized avatar
🎯
Focusing

reyou

🎯
Focusing
View GitHub Profile
package com.company;
import java.util.*;
class Interval {
public int start;
public int end;
public Interval(int _start, int _end) {
start = _start;
// https://www.youtube.com/watch?v=gm8DUJJhmY4
// Binary tree traversal: Preorder, Inorder, Postorder
1. Visit root
2. Visit left sub tree
3. Visit right sub tree
struct Node {
char data;
Node *left;
Node *right;
// https://www.youtube.com/watch?v=86g8jAQug04
#include <iostream>
#include <queue>
using namespace std;
struct Node
{
char data;
Node *left;
Node *right;
} void LevelOrder(Node *root)
struct Node
{
int data;
Node *left;
Node *right;
}
bool IsSubtreeLesser(Node *root, int value)
{
if(root == NULL) return true;
// https://www.youtube.com/watch?v=gcULXE7ViZw
#include <iostream>
using namespace std;
struct Node
{
int data;
Node *right;
Node *left;
}
// find nth fibonacci both recursive and iterative
// 0 1 1 2 3 5 8 13 21
// 0 1 2 3 4 5 6 7 8
function fibo(nth) {
if (nth === 0) {
return 0;
}
if (nth === 1) {
return 1;
// find nth fibonacci both recursive and iterative
// 0 1 1 2 3 5 8 13 21
// 0 1 2 3 4 5 6 7 8
function fibo(nth) {
// return statement
if (nth === 0) {
return 0;
}
if (nth === 1) {
// number edges in longest path
// depth and height are different properties
struct Node
{
int data;
struct Node *left;
struct Node *right;
}
int FindHeight(struct Node *root)
// * Find max connected component in an image
// https://www.geeksforgeeks.org/find-number-of-islands/
// https://www.geeksforgeeks.org/find-the-number-of-islands-set-2-using-disjoint-set/
// https://leetcode.com/problems/number-of-islands/description/
// https://leetcode.com/problems/number-of-islands/discuss/131474/Clean-javascript-solution-using-DFS
// https://leetcode.com/problems/number-of-islands/discuss/131165/Detailed-Explanation-of-the-Java-solution
var input = [
[1, 1, 1, 1, 0],
[1, 1, 0, 1, 0],
[1, 1, 0, 0, 0],
struct BstNode
{
int data;
BstNode *left;
BstNode *right;
};
int FindMin(BstNode *root)
{
if (root == NULL)