Giter Club home page Giter Club logo

assignment-5-cs497's Introduction

Remove Invalid Parenthesis

The time complexity of the above code is O(2^N) The main idea to solve this problem is to use Backtracking. The recursion tree is where we have skipped the 3rd and 6th characters.

Maximum Absolute Difference in BST

My solution would be to traverse the tree, and for every node, find the maximum value node in its left and right subtree. If the difference between the node and its descendants is more than the maximum difference found so far, update it. The time complexity of this solution is O(n^2), where n is the total number of nodes in the binary tree.

Maximum Path Sum in a Binary Tree

If the root is NULL, return 0(Base Case) Call the recursive function to find the max sum for the left and the right subtree In a variable store the maximum of (root->data, maximum of (leftSum, rightSum) + root->data) In another variable store the maximum of previous step and root->data + leftSum + rightSum Return the maximum of the previous step The time complexity of the above code is O(N)

Lexicographical Numbers

Time Complexity: O(N) Using DFS: Always multiply temp by 10 till temp * 10 is greater than n Increment temp by 1 when the last digit of temp is not equal to 9

assignment-5-cs497's People

Watchers

Anh Lam Truong avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.