GithubHelp home page GithubHelp logo

coding-challenges's Introduction

Coding Challenges

A selection of difficult coding problems that can be solved in any programming language. The problems are divided into multiple categories, and each category has its own set of questions.

To add your own solutions, feel free to fork this repo and create your own folder (LANGUAGE-NAME) under the root directory.

Arrays and String

Linked Lists

Stacks and Queues

Trees and Graphs

  1. Implement a function to check if a tree is balanced. For the purposes of this question, a balanced tree is defined to be a tree such that no two leaf nodes differ in distance from the root by more than one.
    boolean isBalanced(TreeNode n)

  2. Given a directed graph, design an algorithm to find out whether there is a route between two nodes.
    boolean isDirectedRoute(Vertex start, Vertex end, Graph g)

  3. Given a sorted (increasing order) array, write an algorithm to create a binary tree with minimal height.
    TreeNode createMinimalBST(int[] arr)

  4. Given a binary search tree, design an algorithm which creates a linked list of all the nodes at each depth (i.e., if you have a tree with depth D, you'll have D linked lists).
    List<LinkedList<TreeNode>> listTreeByDepth(TreeNode head)

  5. Implement a function to check if a binary tree is a binary search tree.
    boolean isBinarySearchTree(TreeNode root)

  6. Write an algorithm to find the 'next' node (i.e., in-order successor) of a given node in a binary search tree where each node has a link to its parent.
    TreeNode nextInOrder(TreeNode n)

  7. Design an algorithm and write code to find the first common ancestor of two nodes in a binary tree. Avoid storing additional nodes in a data structure. NOTE: This is not necessarily a binary search tree.
    TreeNode ancestor(TreeNode c1, TreeNode c2, TreeNode root)

  8. You have two very large binary trees: T1, with millions of nodes, and T2, with hundreds of nodes. Create an algorithm to decide if T2 is a subtree of T1.
    boolean isSubtree(TreeNode t1, TreeNode t2)

  9. You are given a binary tree in which each node contains a value. Design an algorithm to print all paths which sum up to that value. Note that it can be any path in the tree - it does not have to start at the root.

Misc

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.