0% found this document useful (0 votes)
18 views26 pages

Important Coding Program

The document outlines various coding programs categorized into levels (basic, intermediate, advanced) across topics such as conditional statements, strings, arrays, patterns, and dictionaries. Each category includes multiple programming tasks with descriptions and example inputs/outputs. It serves as a comprehensive guide for practicing coding skills in different areas.

Uploaded by

sandeepballina5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views26 pages

Important Coding Program

The document outlines various coding programs categorized into levels (basic, intermediate, advanced) across topics such as conditional statements, strings, arrays, patterns, and dictionaries. Each category includes multiple programming tasks with descriptions and example inputs/outputs. It serves as a comprehensive guide for practicing coding skills in different areas.

Uploaded by

sandeepballina5
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Important Coding

Programs
- WALYS (Life Skills
International Pvt.Ltd)

 Programs on Conditional Statements:

 Basic Level
1.Check Even or Odd
Given an integer, determine if it's even or odd using conditional
statements.

2.Check Positive, Negative, or Zero


Take a number and print whether it's positive, negative, or zero.

3.Find the Largest of Two Numbers


Input two numbers and print the largest.

4.Find the Largest of Three Numbers


Input three numbers and use conditional logic to print the largest.

5.Leap Year Checker


Write a program to check whether a year is a leap year.

6.Character Type Checker


Input a character and determine if it’s an alphabet, digit, or special
character.

7.Vowel or Consonant
Check whether the entered character is a vowel or consonant.

8.Grade Calculator
Given marks (0–100), print the grade using conditions:
Page No: 1
90–100: A
80–89: B
70–79: C
etc.

9.Eligibility for Voting


Input age and print whether the person is eligible to vote (age >= 18).

10.Check Divisibility
Check if a number is divisible by 3 and 5 both, only 3, only 5, or none.

 Intermediate Level

11. Simple Calculator


Take two numbers and an operator (+, -, *, /) and compute the result.

12.Check Triangle Type


Given the lengths of 3 sides, check if the triangle is:

Equilateral
Isosceles
Scalene
Not a triangle

13.Roots of a Quadratic Equation


Input coefficients a, b, c and determine the nature of the roots (real and
equal, real and different, or imaginary).

14.Day of the Week (1-7)


Input a number from 1 to 7 and print the corresponding day.

15.Electricity Bill Calculator

Based on units consumed:


First 100: free
Next 100: ₹5/unit
Above 200: ₹10/unit

16.Login Authentication
Page No: 2
Check entered username and password using hardcoded values.

 Advanced Level
17.ATM Cash Withdrawal Logic
Input withdrawal amount and balance. Validate minimum withdrawal
conditions, multiple of 100, and sufficient balance.

18.Income Tax Calculator


Based on slabs:
0–2.5L: No tax
2.5–5L: 5%
5–10L: 20%
Above 10L: 30%

19.Traffic Light System


Based on color input (red, yellow, green), print action (stop, wait, go).

20.Nested Condition: Student Admission

Marks > 85 and entrance score > 70 → Admission


Else if Marks > 60 and entrance > 60 → Waitlist
Else → Rejected

21.Shopping mall bill calculator

22.Railway ticket fare calculator

 Programs on Strings:

 Easy Level (Basic 1.String Manipulation)


Reverse a String
Input: "hello" → Output: "olleh"

2.Check for Palindrome


Input: "racecar" → Output: True

Page No: 3
3.Count Vowels and Consonants
Input: "abcde" → Output: Vowels: 2, Consonants: 3

4.Remove Duplicates from a String


Input: "programming" → Output: "progamin"

5.Check if Two Strings are Anagrams


Input: "listen", "silent" → Output: True

 Medium Level
6.(Patterns, Frequency, Parsing)
Longest Substring Without Repeating Characters
Input: "abcabcbb" → Output: 3 ("abc")

7.Find First Non-Repeating Character


Input: "aabbccd" → Output: 'd'

8.String Compression
Input: "aaabbccc" → Output: "a3b2c3"

9.Check if One String is Rotation of Another


Input: "waterbottle" and "erbottlewat" → Output: True

10.Group Anagrams
Input: ["eat", "tea", "tan", "ate", "nat", "bat"] → Output: [['eat','tea','ate'],
['tan','nat'], ['bat']]

11.Validate Balanced Brackets


Input: "({[]})" → Output: True

12.Convert Roman to Integer


Input: "MCMXCIV" → Output: 1994

 Hard Level (Dynamic Programming, Advanced Parsing)


13.Longest Palindromic Substring
Input: "babad" → Output: "bab" or "aba"

14.Minimum Insertions to Make String Palindrome


Input: "abcda" → Output: 2

Page No: 4
15.Regular Expression Matching (. and *)
Input: "aab", Pattern: "c*a*b" → Output: True

16.Word Break Problem


Input: "leetcode", Dictionary: ["leet", "code"] → Output: True

17.Decode Ways (like Leetcode #91)


Input: "226" → Output: 3

18.Zigzag Conversion
Input: "PAYPALISHIRING", Rows: 3 → Output: "PAHNAPLSIIGYIR"

19.Multiply Two Large Numbers (Given as Strings)


Input: "123", "456" → Output: "56088"

20.Find All Permutations of a String


Input: "abc" → Output: ["abc", "acb", "bac", "bca", "cab", "cba"]

 Programs on Arrays:
 Easy-Level Array Questions
1.Find the Maximum and Minimum Element in an Array
Given an array of integers, find the minimum and maximum values in the
array.
Input: [3, 5, 1, 2, 4] → Output: Min = 1, Max = 5

2.Check if the Array is Sorted


Determine if the array is sorted in ascending or descending order.
Input: [1, 2, 3, 4, 5] → Output: True

3.Reverse an Array
Write a function to reverse a given array in place.
Input: [1, 2, 3, 4] → Output: [4, 3, 2, 1]

4.Find the Sum of AllElements in the Array


Calculate the total sum of all integers in the array.
Input: [1, 2, 3, 4, 5] → Output: 15

5.Find the Second Largest Element in the Array


Return the second highest element in the given array.
Page No: 5
Input: [12, 35, 1, 10, 34, 1] → Output: 34

6.Remove Duplicates from a Sorted Array


Given a sorted array, remove duplicates in-place such that each element
appears only once.
Input: [1, 1, 2, 2, 3] → Output: [1, 2, 3]

7.Move All Zeros to the End of the Array


Move all 0’s to the end while maintaining the order of non-zero elements.
Input: [0, 1, 0, 3, 12] → Output: [1, 3, 12, 0, 0]

 Medium-Level Array Questions

8.Find the Kth Largest/Smallest Element in an Array


Find the kth largest (or smallest) element in an unsorted array.
Input: arr = [7, 10, 4, 3, 20, 15], k = 3 → Output: 7 (3rd smallest)

9.Find the Majority Element


Find the element that appears more than n/2 times, if any.
Input: [2, 2, 1, 1, 2, 2, 2] → Output: 2

10.Maximum Subarray Sum (Kadane’s Algorithm)


Find the contiguous subarray (with at least one number) which has the
largest sum.
Input: [-2,1,-3,4,-1,2,1,-5,4] → Output: 6 ([4,-1,2,1])

11.Subarray with Given Sum (for Positive Integers)


Given an array and a sum, find a subarray with the given sum (only for
positive integers).
Input: arr = [1, 2, 3, 7, 5], sum = 12 → Output: Subarray found at index 2
to 4

12.Sort 0s, 1s and 2s (Dutch National Flag Problem)


Sort an array consisting of only 0s, 1s, and 2s without using extra space.
Input: [0, 1, 2, 0, 1, 2] → Output: [0, 0, 1, 1, 2, 2]

13.Rotate the Array by K Elements


Rotate the array to the right by k steps in-place.
Input: nums = [1,2,3,4,5,6,7], k = 3 → Output: [5,6,7,1,2,3,4]
Page No: 6
14.Merge Two Sorted Arrays Without Extra Space
Given two sorted arrays, merge them without using extra space so that
the first contains the smallest elements.
Input: A = [1, 3, 5, 7], B = [0, 2, 6, 8, 9] → Output:
A = [0, 1, 2, 3], B = [5, 6, 7, 8, 9]

15.Find All Pairs with a Given Sum


Find all pairs of elements that sum up to a given number.
Input: arr = [1, 5, 7, -1, 5], sum = 6 → Output: (1,5), (7,-1), (1,5)

16.Equilibrium Index of an Array


Find an index where the sum of elements on left is equal to the sum of
elements on right.
Input: [-7, 1, 5, 2, -4, 3, 0] → Output: Index 3

 Hard-Level Array Question


17.Trapping Rainwater #Try in leetcode
Given n non-negative integers representing the elevation map, compute
how much water it can trap after raining.
Input: [0,1,0,2,1,0,1,3,2,1,2,1] → Output: 6

18.Maximum Product Subarray


Find the contiguous subarray within an array that has the largest
product.
Input: [2,3,-2,4] → Output: 6

19.Longest Consecutive Sequence


Given an unsorted array, find the length of the longest consecutive
elements sequence.
Input: [100, 4, 200, 1, 3, 2] → Output: 4 ([1,2,3,4])

20.Median of Two Sorted Arrays


Given two sorted arrays, return the median of the two arrays. Must run in
O(log(min(n,m))) time.
Input: nums1 = [1, 3], nums2 = [2] → Output: 2.0

Page No: 7
 Programs on Patterns:

 Easy Level Patterns

1. Right-Angled Triangle of Stars


Input: n = 5
Output:

*
**
***
****
*****

2. Inverted Right-Angled Triangle


Input: n = 4
Output:

****
***
**
*
3. Square of Stars
Input: n = 3
Output:

***
***
***

4. Right-Aligned Triangle
Input: n = 4
Output:

*
**
***
****
5. Number Triangle
Input: n = 4

Page No: 8
Output:

1
12
123
1234

6. Inverted Number Triangle


Input: n = 5
Output:

12345
1234
123
12
1

7. Floyd’s Triangle
Input: n = 4
Output:

1
23
456
7 8 9 10

 Intermediate Level (8–14)


8. Pascal’s Triangle
Input: n = 5
Output:

1
11
121
1331
14641

9. Diamond Star Pattern


Input: n = 3
Output:
*
***
Page No: 9
*****
***
*
10. Butterfly Pattern
Input: n = 4
Output:

* *
** **
*****
** **
* *
11. 0-1 Triangle
Input: n = 5
Output:

1
0 1
1 01
0 101
1 0101

12. Hourglass Pattern


Input: n = 4
Output:

*********
*** ***
** **
**
**
** **
*** ***
********

13. Number Pyramid


Input: n = 4
Output:

1
22
Page No: 10
333
4444

14. Alternating Binary Triangle


Input: n = 4
Output:

1
01
101
0101

 Advanced Level (15–20)

15. Spiral Matrix Pattern


Input: n = 3
Output:

123
894
765

16. Zigzag Pattern


Input: n = 3 (rows), m = 9 (cols)
Output:

* * *
*****
* * *

17. Palindromic Number Triangle


Input: n = 5
Output:

1
212
32123
4321234
543212345

Page No: 11
18. Hollow Diamond
Input: n = 3
Output:

*
**
* *
**
*

19. Concentric Square Pattern


Input: n = 4
Output:

4444444
4333334
4322234
4321234
4322234
4333334
4444444

20. Sandglass Pattern


Input: n = 4
Output:
********
* *
* *
**
**
* *
* *
********

Page No: 12
 Programs in Dictionary:
 Easy Level (1–7)
1. Frequency of Characters
Description: Count frequency of each character in a string.
Input: "hello world"
Output: {'h':1, 'e':1, 'l':3, 'o':2, ' ':1, 'w':1, 'r':1, 'd':1}

2. Merge Two Dictionaries


Description: Merge two dictionaries. If a key appears in both, add their
values.
Input: d1 = {'a': 1, 'b': 2}, d2 = {'b': 3, 'c': 4}
Output: {'a': 1, 'b': 5, 'c': 4}

3. Invert Dictionary
Description: Swap keys and values.
Input: {'a': 1, 'b': 2}
Output: {1: 'a', 2: 'b'}

4. Check Key Existence


Description: Check if a key exists in a dictionary.
Input: "b" in {'a': 1, 'b': 2}
Output: True

5. Sum of Dictionary Values


Input: {'a': 10, 'b': 20, 'c': 30}
Output: 60

6. Sort Dictionary by Values


Input: {'a': 3, 'b': 1, 'c': 2}
Output: [('b', 1), ('c', 2), ('a', 3)]

7. Top N Frequent Words


Description: Find the top 2 frequent words.
Input: "apple banana apple orange banana apple"
Output: {'apple': 3, 'banana': 2}

 Medium Level (8–14)


8. Group Anagrams
Input: ["eat", "tea", "tan", "ate", "nat", "bat"]
Output: [["eat","tea","ate"],["tan","nat"],["bat"]]

Page No: 13
9. Longest Substring Without Repeating Characters
Input: "abcabcbb"
Output: 3 (substring is "abc")

10. Count Pairs with Given Sum


Input: arr = [1, 5, 7, -1], sum = 6
Output: 2 (pairs: (1,5), (7,-1))

11. First Non-Repeating Character


Input: "aabbcddeff"
Output: 'c'

12. Subarray Sum Equals K


Input: nums = [1,1,1], k = 2
Output: 2 (subarrays: [1,1] at index 0 and 1)

13. Character Replacement to Make All Same


Input: "AABABBA", k = 1
Output: 4 (Change 1 B to A to make "AABA")

14. Find All Duplicates


Input: [4,3,2,7,8,2,3,1]
Output: [2,3]

 Hard Level (15–20)


15. Word Pattern
Input: pattern = "abba", s = "dog cat cat dog"
Output: True

16. Subdomain Visit Count


Input: ["900 google.mail.com", "50 yahoo.com", "1 intel.mail.com", "5
wiki.org"]
Output:

["901 mail.com", "50 yahoo.com", "900 google.mail.com", "5 wiki.org", "1


intel.mail.com", "951 com"]
17. Isomorphic Strings
Input: s = "egg", t = "add"
Output: True

18. Minimum Window Substring


Input: s = "ADOBECODEBANC", t = "ABC"
Page No: 14
Output: "BANC"

19. Count Distinct Elements in Every Window


Input: arr = [1, 2, 1, 3, 4, 2, 3], k = 4
Output: [3, 4, 4, 3]

20. Find Original Array From Doubled Array


Input: [1,3,4,2,6,8]
Output: [1,3,4]

 Programs on Stack:
 Easy Level (Basics of Stack)
1.Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']',
determine if the input string is valid.
Leetcode 20

2.Min Stack
Design a stack that supports push, pop, top, and retrieving the minimum
element in constant time.
Leetcode 155

3.Implement Stack using Queues


Use two queues to implement a stack.
Leetcode 225

4.Reverse a Stack using Recursion


Reverse a stack without using extra space (only stack function calls are
allowed).

5.Evaluate Reverse Polish Notation


Evaluate the value of an arithmetic expression in Reverse Polish Notation
(Postfix).
Leetcode 150

 Medium Level (Stack with logic + state)

6.Next Greater Element


For each element in the array, find the next greater element to its right.
Page No: 15
Leetcode 496

7.Daily Temperatures
Return an array such that each index tells you how many days you would
have to wait for a warmer temperature.
Leetcode 739

8.Largest Rectangle in Histogram


Find the largest rectangle that can be formed in a histogram.
Leetcode 84

9.Remove K Digits
Remove k digits from the number string to make it the smallest possible
number.
Leetcode 402

10.Asteroid Collision
Simulate the collision of asteroids moving in opposite directions.
Leetcode 735

11.Next Greater Element in Circular Array


The array wraps around — find the next greater for each element.
Leetcode 503

 Hard Level (Advanced Stack Usage or Stack + DSU/Tree/Greedy)

12.Maximal Rectangle in Binary Matrix


Use stack logic with histogram conversion row-wise to find the maximal
rectangle.
Leetcode 85

13.Remove Duplicate Letters


Return the smallest in lexicographical order string after removing
duplicate letters, keeping only one occurrence of each.
Leetcode 316

14.Trapping Rain Water


Use two-pointer or stack method to calculate how much water can be
trapped.
Page No: 16
Leetcode 42

15.Exclusive Time of Functions


Given logs of function calls, return the exclusive time of each function
using a stack.
Leetcode 636

 Programs on Queue:
 Beginner Level (1-6)

1.Implement a Queue using Arrays


2.Implement a Queue using Two Stacks
3.Implement a Stack using Two Queues
4.Circular Queue Implementation
5.Design a Queue with enqueue(), dequeue(), front() and isEmpty()
operations
6.Reverse the first K elements of a Queue
Given a queue and an integer K, reverse the first K elements of the
queue.

 Intermediate Level (7-14)

7.Generate Binary Numbers from 1 to N using a Queue


8.Interleave the First Half of the Queue with the Second Half
9.Implement a Deque (Double-Ended Queue)
10.First Non-Repeating Character in a Stream
Maintain a queue to track characters and print the first non-
repeating one at each step.

11.Rotten Oranges (Matrix + BFS using Queue)


A BFS traversal problem with queues representing time-based
spread.

12.Level Order Traversal of a Binary Tree (BFS)


13.Check if a given Queue can be sorted using a Stack
14.LRU Cache Implementation using Deque and HashMap

 Advanced Level (15-20)

Page No: 17
15.Sliding Window Maximum
Use a Deque to find the max in each window of size k.

16.Design a Hit Counter (Leetcode-like problem)


Count number of hits received in the past 5 minutes using queue
timestamps

17.Minimum Time to Complete All Tasks (CPU Scheduling)


Round Robin or task scheduling logic with queues.

18.Clone a Graph using BFS with Queue


19. Implement a Multi-threaded Bounded Blocking Queue
20.Minimum Cost of Connecting Ropes using Priority Queue

 Programs on Linked List:


 Beginner Level (Basic Operations)
1. Reverse a Linked List

Level: Easy
Description: Reverse the nodes of a singly linked list.
Input: 1 -> 2 -> 3 -> 4 -> NULL
Output: 4 -> 3 -> 2 -> 1 -> NULL

2. Detect a Cycle in a Linked List

Level: Easy
Description: Check whether the linked list has a cycle.
Input: 3 -> 2 -> 0 -> -4 with tail.next = node at index 1
Output: true

3. Merge Two Sorted Linked Lists

Level: Easy
Description: Merge two sorted linked lists into one sorted list.
Input: 1 -> 2 -> 4, 1 -> 3 -> 4
Output: 1 -> 1 -> 2 -> 3 -> 4 -> 4

4. Remove Duplicates from Sorted List


Page No: 18
Level: Easy
Input: 1 -> 1 -> 2 -> 3 -> 3
Output: 1 -> 2 -> 3

5. Find Middle of a Linked List

Level: Easy
Input: 1 -> 2 -> 3 -> 4 -> 5
Output: 3

 Intermediate Level
6. Remove N-th Node From End

Level: Medium
Input: 1 -> 2 -> 3 -> 4 -> 5, n = 2
Output: 1 -> 2 -> 3 -> 5

7. Add Two Numbers Represented by Linked Lists

Level: Medium
Input: (2 -> 4 -> 3) + (5 -> 6 -> 4)
Output: 7 -> 0 -> 8

8. Intersection of Two Linked Lists

Level: Medium
Input: Two lists intersect at node with value 8
Output: Node with value 8

9. Reverse Nodes in k-Group

Level: Medium
Input: 1 -> 2 -> 3 -> 4 -> 5, k = 3
Output: 3 -> 2 -> 1 -> 4 -> 5

10. Flatten a Multilevel Doubly Linked List

Page No: 19
Level: Medium
Description: Flatten a linked list with child pointers.
Input: 1->2->3->4->5->6 with 3.child = 7->8->9
Output: 1->2->3->7->8->9->4->5->6

11. Copy List with Random Pointer

Level: Medium
Input: List with random pointers to any node or null
Output: Deep copy of the list

12. Rotate Linked List

Level: Medium
Input: 1 -> 2 -> 3 -> 4 -> 5, k = 2
Output: 4 -> 5 -> 1 -> 2 -> 3

 Advanced Level
13. Merge K Sorted Lists

Level: Hard
Input: [[1,4,5],[1,3,4],[2,6]]
Output: 1->1->2->3->4->4->5->6

14. LRU Cache (Using Doubly Linked List + HashMap)

Level: Hard
Operations: put(1,1), put(2,2), get(1), put(3,3)
Output: Maintains most recently used items

15. Reverse a Linked List in Range [m, n]

Level: Medium
Input: 1 -> 2 -> 3 -> 4 -> 5, m = 2, n = 4

Page No: 20
Output: 1 -> 4 -> 3 -> 2 -> 5

16. Detect and Remove Loop in a Linked List

Level: Medium
Input: Loop exists at node 3
Output: List without loop

17. Sort a Linked List Using Merge Sort

Level: Hard
Input: 4 -> 2 -> 1 -> 3
Output: 1 -> 2 -> 3 -> 4

18. Convert Binary Number in Linked List to Integer

Level: Easy
Input: 1 -> 0 -> 1
Output: 5

19. Find the Intersection Point of Y-shaped Linked Lists

Level: Medium
Input: Lists merge at node 10
Output: Node with value 10

20. Clone a Linked List with Next and Arbitrary Pointer


Level: Hard
Input: A list where each node has next and random pointers
Output: Deep copy of list

 Programs on Trees:
 Basic Level (1–7)
1. Inorder Traversal of Binary Tree

Difficulty: Easy
Traverse a binary tree in inorder without using recursion.
Input:
1
\
Page No: 21
2
/
3
Output: [1, 3, 2]

2. Check if Two Trees are Identical

Difficulty: Easy
Check if two binary trees are structurally identical and have the same
node values.
Input: Two trees with root values 1 and same structure.
Output: True

3. Maximum Depth of Binary Tree

Difficulty: Easy
Return the depth of a binary tree.
Input:
3
/\
9 20
/\
15 7
Output: 3

4. Mirror of a Binary Tree

Difficulty: Easy
Create a mirror image of a binary tree.
Input: [4,2,7,1,3,6,9]
Output: [4,7,2,9,6,3,1]

5. Count Leaf Nodes in Binary Tree

Difficulty: Easy
Page No: 22
Input:
1
/\
2 3
Output: 2

6. Level Order Traversal

Difficulty: Easy
Return nodes level by level.
Input: [3,9,20,null,null,15,7]
Output: [[3], [9, 20], [15, 7]]

7. Check if Tree is Symmetric

Difficulty: Easy
Check whether a tree is a mirror of itself.
Input: [1,2,2,3,4,4,3]
Output: True

 Medium Level (8–14)


8. Lowest Common Ancestor in Binary Tree

Difficulty: Medium
Find LCA of two given nodes in binary tree.
Input: Tree root and nodes p=5, q=1
Output: 3

9. Validate Binary Search Tree (BST)

Difficulty: Medium
Check whether a binary tree is a valid BST.
Input: [2,1,3]
Output: True

10. Construct Binary Tree from Inorder and Preorder Traversal

Difficulty: Medium
Input:
Preorder: [3,9,20,15,7]
Inorder: [9,3,15,20,7]
Page No: 23
Output: Root of constructed tree.

11. Diameter of Binary Tree

Difficulty: Medium
Return the longest path between any two nodes.
Input: [1,2,3,4,5]
Output: 3

12. Binary Tree Right Side View

Difficulty: Medium
Return the values of the nodes you can see from the right side.
Input: [1,2,3,null,5,null,4]
Output: [1,3,4]

13. Find All Root-to-Leaf Paths with Target Sum

Difficulty: Medium
Return all paths where the sum of nodes equals target.
Input: Tree and target sum = 22
Output: [[5,4,11,2], [5,8,4,5]]

14. Zigzag Level Order Traversal

Difficulty: Medium
Input: [3,9,20,null,null,15,7]
Output: [[3],[20,9],[15,7]]

 Hard Level (15–20)

15. Serialize and Deserialize Binary Tree

Difficulty: Hard
Convert a binary tree to a string and back.
Input: [1,2,3,null,null,4,5]
Output: Tree after deserialization should be identical.

Page No: 24
16. Recover Binary Search Tree

Difficulty: Hard
Two nodes of a BST are swapped. Recover the BST.
Input: [3,1,4,null,null,2]
Output: Corrected BST: [2,1,4,null,null,3]

17. Count Number of Unique BSTs (Catalan Numbers)

Difficulty: Hard
Given n, how many structurally unique BSTs can be made?
Input: 3
Output: 5

18. Binary Tree Maximum Path Sum

Difficulty: Hard
Find the path with the maximum sum.
Input: [-10,9,20,null,null,15,7]
Output: 42

19. Convert Sorted Array to Height-Balanced BST

Difficulty: Medium–Hard
Input: [-10, -3, 0, 5, 9]
Output: Balanced BST

20. Tree to Doubly Linked List (In-place)

Difficulty: Hard
Convert BST to circular doubly linked list in-place.
Input: BST: [4,2,5,1,3]
Output: Circular doubly linked list

Page No: 25
Page No: 26

You might also like