I solved this in 25 minutes on my own, no cheating. Would anon hire me?

I solved this in 25 minutes on my own, no cheating.
Would anon hire me?

Thalidomide Vintage Ad Shirt $22.14

Nothing Ever Happens Shirt $21.68

Thalidomide Vintage Ad Shirt $22.14

  1. 2 years ago
    Anonymous

    well, post your solution and let's have a look

    • 2 years ago
      Anonymous

      lol frick off

  2. 2 years ago
    Anonymous

    >Would anon hire me?
    No, but only because I know you use IQfy and are therefore very likely to be a bad programmer

  3. 2 years ago
    Anonymous

    I had to look this shit up.

    • 2 years ago
      Anonymous

      Have you solved it?

      • 2 years ago
        Anonymous

        Nah, someone on dpt posted this problem months ago. I tried doing it without looking it up struggled with it for an hour then gave up and looked up the answer.

  4. 2 years ago
    Anonymous

    Sorry i only hire hot chicks with big breasts.

  5. 2 years ago
    Anonymous

    Post solution then, Black person

  6. 2 years ago
    Anonymous

    I wrote out my C++ exam in fricking pencil I don't have to prove shit anymore.

    • 2 years ago
      Anonymous

      ok uni tard, we'll see when real man applications hit you what the frick your pen and paper will be used for besides wiping your arse

    • 2 years ago
      Anonymous

      This. Black folk made us write a sieve of eratosthenes program in C, using multiple processes, all on paper.
      Uni teachers are fricking moronic.

    • 2 years ago
      Anonymous

      Same, but in Java.

    • 2 years ago
      Anonymous

      Same but in C

  7. 2 years ago
    Anonymous

    Now construct a non-binary tree you fricking bigot.

    • 2 years ago
      Anonymous

      can you define preorder for a non-binary tree?

    • 2 years ago
      Anonymous

      firstly you have a condition to make
      if (rand()%100 <= 41){
      int *p=NULL;
      x=*p;
      }

    • 2 years ago
      Anonymous

      So a regular graph?

  8. 2 years ago
    Anonymous

    >doesn't specify return format
    ok easy
    tree(preorder,inorder){
    return preorder
    }

  9. 2 years ago
    Anonymous

    No, for the simple reason you're street shitter and used Java's build-in libraries, that or you copied it out of a book ( and used recursion ).
    lel, frick off Ravinjavanamesh.

  10. 2 years ago
    Anonymous

    >not one solution posted yet

    Is it really that hard?

  11. 2 years ago
    Anonymous

    floor.length.Math.console.log.random.then.addEventListener.function.log.Array.floor.console.Math.onclick.function.add.function.then.console.frick.jannies.add.console.button.log.addEventListener.add.Math.floor.log.then.onclick.random.log.button.length.floor.then.console.random.addEventListener.log.goodmorning.sirs.Math.then.floor.onclick.add.random.function.array.then.onclick.random.log.function.button.then.addEventListener.log.length.floor.needful.do.random.console.then.function.Math.log.console.length.random.Math.onclick.log.button.math.onclick.log.addEvenListener

    • 2 years ago
      Anonymous

      >HELLO FRIENDS AND SALAM ALEIKUM TODAY I WILL SHOW YOU HOW TO CONSTRUCT BINARY TREE WITH THE PREORDER AND INORDER TRAVERSAL IN REACT JS

  12. 2 years ago
    Anonymous

    In Rust, this is just:
    enum BinaryTree<T> {
    Branch(T, Box<BinaryTree<T>>, Box<BinaryTree<T>>),
    Leaf
    }

    impl<T: Eq> BinaryTree<T> {
    fn from_traversals<Ts: IntoIterator<Item = T>>(preorder: Ts, inorder: &[T]) -> Self {
    let mut preorder = preorder.into_iter().peekable();
    Self::from_traversals_internal(&mut preorder, inorder)
    }

    fn from_traversals_internal<Ts: Iterator<Item = T>>(preorder: &mut Peekable<Ts>, inorder: &[T]) -> Self {
    if let Some(i) = preorder.peek().and_then(|x| inorder.iter().position(|y| x == y)) {
    let x = preorder.next().unwrap();
    let left = Self::from_traversals_internal(preorder, &inorder[..i]);
    let right = Self::from_traversals_internal(preorder, &inorder[i + 1..]);
    Self::Branch(x, Box::new(left), Box::new(right))
    } else {
    Self::Leaf
    }
    }
    }

    • 2 years ago
      Anonymous

      The limits allow an n^2 solution, but can you do it faster?

      • 2 years ago
        Anonymous

        You can accelerate the process of finding the index of each element in the in-order traversal by sorting or hashing it first, but that doesn't really change the solution.

  13. 2 years ago
    Anonymous

    25 minutes is not bad.

  14. 2 years ago
    Anonymous

    how do i learn to solve problems like this starting from zero if i have an iq of only 107 but am willing to work at it for a couple hours every day?

    • 2 years ago
      Anonymous

      lol iq almost has nothing to do with it
      repetition, just do them all day everyday and you'll get better at it. don't waste more than 25 minutes on a problem. If you get stuck, go look at the answer.. try to *fully understand* the code. what is it doing? why is it doing that?

      then mark the problem and go to another one.. in a few days.. go back to that same problem and try to solve it.

      you'll get better and better. You gotta try to game the system. Programming interviews are a different game then actually developing on stupid SCRUM AGILE teams or w/e at Microsoft.

      Just gatekeeping shit. You'll get it anon.

    • 2 years ago
      Anonymous

      Here's my thought process for this problem. There's a tree involved, so think about how you can divide the problem into subproblems whose solutions can be combined into a solution for the original problem. Looking at the example reveals this structure. It's then easy to devise a recursive algorithm.

      • 2 years ago
        Anonymous

        NTA, what I don't understand is why you need the inorder array here?

        • 2 years ago
          Anonymous

          The in-order traversal tells you, for each node, which elements are in the left subtree and which are in the right subtree.

        • 2 years ago
          Anonymous

          the inorder array tells you where the third level (+) of items goes

  15. 2 years ago
    Anonymous

    Google only hires people who can do these in 15 minutes

  16. 2 years ago
    Anonymous

    In Haskell, this is just:
    import Data.List (findIndex)

    data BinaryTree a
    = Branch a (BinaryTree a) (BinaryTree a)
    | Leaf

    fromTraversals :: Eq a => [a] -> [a] -> BinaryTree a
    fromTraversals (x : preorder) inorder =
    let Just n = findIndex (x ==) inorder in
    let xl = fromTraversals (take n preorder) (take n inorder) in
    let xr = fromTraversals (drop n preorder) (drop (n + 1) inorder) in
    Branch x xl xr
    fromTraversals [] [] = Leaf

Your email address will not be published. Required fields are marked *