Skip to content

Instantly share code, notes, and snippets.

View TiltOfABinaryTree.txt
Description:
Tilt of a node is the absolute value of difference between sum of nodes in it's left subtree and right subtree. Tilt of the whole tree is represented as the sum of tilt of all it's nodes.
Question Name:
Tilt Of a Binary Tree
Question Link:
https://www.pepcoding.com/resources/online-java-foundation/binary-tree/tilt-of-binary-tree/ojquestion
Question Statement:
View Is a Binary Search Tree
Description:
In this video, we explain about a binary search tree and discuss the solution for the problem where we are required to find if a tree is a BST or not in minimum time and space complexity.
Question Name:
Is a Binary Search Tree
Article Link:
https://www.pepcoding.com/resources/online-java-foundation/binary-tree/is_a_binary_search_tree/topic
Question Statement:
View Is Balanced Tree
Description:
In this video, we explain about balanced binary tree and discuss the solution for the problem where we are required to find if a binary tree is balanced or not
Question Name:
Is Balanced Tree
Article Link:
https://www.pepcoding.com/resources/online-java-foundation/binary-tree/is_balanced_tree/topic
Question Statement:
View Largest BST Subtree
Description:
In this video, we have explained about subtree and discuss the solution for the problem where we are required to find the root largest BST subtree in binary tree.
Question Name:
Largest BST Subtree
Article Link:
https://www.pepcoding.com/resources/online-java-foundation/binary-tree/largest_bst_subtree/topic
Question Statement:
View Binary Search Tree Introduction
Description:
In this video, we will introduce the Binary Search Tree, a variation of Binary tree where the left node is always smaller than the right node and the left subtree is always smaller than the right subtree.
Video Name:
Binary Search Tree-Introduction
Video Link:
https://www.youtube.com/watch?v=wE5nFfdr7Ls&list=PL-Jc9J83PIiGl_-iS5k7R7SZoZPt0Fab2
@Shivani13121007
Shivani13121007 / How Many Numbers Are Smaller Than the Current Number
Created Oct 23, 2021
How Many Numbers Are Smaller Than the Current Number
View How Many Numbers Are Smaller Than the Current Number
class Solution {
public int[] smallerNumbersThanCurrent(int[] nums) {
int[] ans = new int[nums.length];
// Brute Technique
// for(int i=0;i<nums.length;i++)
// {
// int c=0;
// for(int j=0;j<nums.length;j++)
@Shivani13121007
Shivani13121007 / Minimum Number of Moves to Seat Everyone
Created Oct 23, 2021
Minimum Number of Moves to Seat Everyone
View Minimum Number of Moves to Seat Everyone
class Solution {
public int minMovesToSeat(int[] seats, int[] students) {
Arrays.sort(seats);
Arrays.sort(students);
int ans = 0;
for(int i=0;i<seats.length;i++)
{
ans+= Math.abs(seats[i] - students[i]);
View Sorting the Sentence
class Solution {
public String sortSentence(String s) {
String[] arr = s.split(" ");
String[] res = new String[arr.length];
String fa = "";
for(int i=0;i<arr.length;i++)
{
String str = arr[i];
String toAdd = "";
@Shivani13121007
Shivani13121007 / Maximum Product Difference Between Two Pairs
Created Oct 23, 2021
Maximum Product Difference Between Two Pairs
View Maximum Product Difference Between Two Pairs
class Solution {
public int maxProductDifference(int[] nums) {
int n = nums.length;
Arrays.sort(nums);
int a = nums[0];
int b = nums[1];
int c = nums[n-1];
int d = nums[n-2];
@Shivani13121007
Shivani13121007 / Maximum Product of Two Elements in an Array
Created Oct 23, 2021
Maximum Product of Two Elements in an Array
View Maximum Product of Two Elements in an Array
class Solution {
public int maxProduct(int[] nums) {
int n = nums.length;
Arrays.sort(nums);
int res = (nums[n-1] -1) * (nums[n-2] -1);
return res;
}
}