View TiltOfABinaryTree.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Balanced Tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Is a Binary Search Tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 Largest BST Subtree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
View How Many Numbers Are Smaller Than the Current Number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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++) |
View Minimum Number of Moves to Seat Everyone
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = ""; |
View Maximum Product Difference Between Two Pairs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]; | |
View Maximum Product of Two Elements in an Array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
OlderNewer