Skip to content

Latest commit

 

History

History
96 lines (64 loc) · 2.3 KB

JTG SDE backend.md

File metadata and controls

96 lines (64 loc) · 2.3 KB
  1. Given a string S, find the second non-repeatign character of S. String contains lower case characters only. If no such character exist then return "-".
    Input

    abbcdefgabbcdabcg

    output: f

    NOTE: the solution should be implemented with O(N) time complexity and constant space.

  2. A tree is considered special if the sums of all the nodes at each level are in AP, Given the root note of a binary tree. Return an array representting the minimum number that can be added at each

    Input

       3
      / \
     2   7
     \
      15
    

    output: [0, 0, 0]

    Input

       17
      / \
     11  5
          \
          12
    

    output: [0, 0, 3]

  3. Given a linked list, arrange the linked list in the manner of alternate last and first. Make sure to ......(not readable) NOTE the solution should be implemented with O(n) time complexity and constant space.

    Input

       1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8

    output: 8 -> 1 -> 7 -> 2 -> 6 -> 3 -> 5 -> 4

  4. Given a sorted array containing N integers, both +ve and -ve. Create another array containing the sqares of all the elements in the input array and return it ... (not readable) NOTE Exptected time complexity O(n)

    Input

     [-7, -5, -2, 0, 1]

    output: [0, 1, 4, 25, 49]

  5. Provided a sorted linked list, write a program to delete all the nodes having duplicate no.s Create another array containing the sqares of all the elements in the input array and return it ... (not readable) NOTE Exptected time complexity O(n) and constant space.

    Input

     2 -> 4 -> 5 -> 5 -> 6 -> 6 -> 8

    output: 2 -> 4 -> 8

    Input

     2 -> 2 -> 2 -> 4 -> 5 

    output: 4 -> 5

  6. Provided a binary tree containing digits only from 0 - 9, each root to leaf path represents a no. Return the total sum of Return an array representting the minimum number that can be added at each

    Input

       2
      / \
     3   5
    

    output: 48, explanation: 2 -> 3 == 23, 2 -> 5 == 25