Linkedin Interview Question for Software Engineers

Country: United States
Interview Type: In-Person

Comment hidden because of low score. Click to expand.
of 3 vote

Looking for interview experience sharing and coaching?

Visit AONECODE.COM for private lessons by FB, Google and Uber engineers

Our ONE TO ONE class offers

SYSTEM DESIGN Courses (highly recommended for candidates of FB, LinkedIn, Amazon, Google & Uber etc.)
ALGORITHMS (conquer DP, Greedy, Graph, Advanced Algos & Clean Coding),
latest interview questions sorted by companies,
mock interviews.

Our students got hired from G, U, FB, Amazon, LinkedIn and other top-tier companies after weeks of training.

Feel free to email us with any questions. Thanks!

Get sqrt(x):

int sqrt(int x) {
        //check for x >= 0 if necessary
        int r = x;
        while (r * r > x)
            r = (r + x / r) / 2;
        return r ;

BST Implementation:

class BinarySearchTree {
    /* Class containing left and right child of current node and key value*/
    class Node {
        int key;
        Node left, right;
        public Node(int item) {
            key = item;
            left = right = null;
    // Root of BST
    Node root;
    // Constructor
    BinarySearchTree() { 
        root = null; 
    // This method mainly calls insertRec()
    void insert(int key) {
       root = insertRec(root, key);
    /* A recursive function to insert a new key in BST */
    Node insertRec(Node root, int key) {
        /* If the tree is empty, return a new node */
        if (root == null) {
            root = new Node(key);
            return root;
        /* Otherwise, recur down the tree */
        if (key < root.key)
            root.left = insertRec(root.left, key);
        else if (key > root.key)
            root.right = insertRec(root.right, key);
        /* return the (unchanged) node pointer */
        return root;
    // This method mainly calls InorderRec()
    void inorder()  {
    // A utility function to do inorder traversal of BST
    void inorderRec(Node root) {
        if (root != null) {

   // This method mainly calls deleteRec()
    void deleteKey(int key)
        root = deleteRec(root, key);
    /* A recursive function to insert a new key in BST */
    Node deleteRec(Node root, int key)
        /* Base Case: If the tree is empty */
        if (root == null)  return root;
        /* Otherwise, recur down the tree */
        if (key < root.key)
            root.left = deleteRec(root.left, key);
        else if (key > root.key)
            root.right = deleteRec(root.right, key);
        // if key is same as root's key, then This is the node
        // to be deleted
            // node with only one child or no child
            if (root.left == null)
                return root.right;
            else if (root.right == null)
                return root.left;
            // node with two children: Get the inorder successor (smallest
            // in the right subtree)
            root.key = minValue(root.right);
            // Delete the inorder successor
            root.right = deleteRec(root.right, root.key);
        return root;

- aonecoding November 03, 2017 | Flag Reply

Add a Comment

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.


is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More


CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More