Flipkart – Overall Interview Questions + coding Solutions- codewindow.in

Hot Topics

Topics

1. TCS Technical Questions
2. CTS Technical Questions
3. Infosys Technical Questions
4. Capgemini Technical Questions
5. IBM Technical Questions
6. Wipro Technical Questions
7. Accenture Technical Questions
8. Deloitte Technical Questions
9. MindTree Technical Questions
10. NTT Data Technical Questions
11. Persistent Technical Questions
12. Hexaware Technical Questions
13. ZOHO Technical Questions
14. HCL Technical Questions
15. Genpact Technical Questions
16. udostres Technical Questions
17. samsung research Technical Questions
18. Media.net Technical Questions
19. Tejas Network Technical Questions
20. Kantar Technical Questions
21. Itron Technical Questions
22. Fractal Analyst Technical Questions
23. Lexmark International Technical Questions
24. Infeneon Technologies Technical Questions
25. Razorpay Technical Questions
26. payu Technical Questions
27. Navi Technical Questions
28. Tata Cliq Technical Questions
29. Grab Technical Questions
30. Schlumberger Technical Questions
31. Latenview Analytics Technical Questions
32. GreayB Technical Questions
33. Tally solution Technical Questions
34. Amagi Technical Questions
35. HFCL Technical Questions
36. Slice Technical Questions
37. Larsen & Turbo Technical Questions
38. Zenser Technical Questions
39. Siemens Technical Questions
40. Exon Movie Technical Questions
41. Gupshup Technical Questions
42. Smart cube Technical Questions
43. Celebal Tech Technical Questions
44. Teg Analytics Technical Questions
45. Commvault Systems Technical Questions
46. Incuture Technical Questions
47. Tiger Technical Questions
48. Bridgei2i Technical Questions
49. code nation Technical Questions
50. DE Show Technical Questions
51. Amazon Technical Questions
52. Flipkart Technical Questions
53. Morgan Stanly Technical Questions
54. duutsche bank Technical Questions
55. textas Technical Questions
56. pwc Technical Questions
57. salesforce Technical Questions
58. optum Technical Questions
59. Nvidia Technical Questions
60. Itc Infotech Technical Questions
61. linkedin Technical Questions
62. Adobe Technical Questions

Filpkart Solution

Technical Round

Find the second maximum element in an unsorted array of integers, using single for loop.

#include <iostream>
using namespace std;

int main() {
  int n;
  cin >> n;
  int arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int first = -1, second = -1;
  for (int i = 0; i < n; i++) {
    if (arr[i] > first) {
      second = first;
      first = arr[i];
    } else if (arr[i] > second && arr[i] != first) {
      second = arr[i];
    }
  }
  cout << second << endl;
  return 0;
}
/*
OUTPUT
5
7
8
9
3
6
8 
*/

Design a Data Structure SpecialStack that supports all the stack operations like push(), pop(), isEmpty(), isFull() and an additional operation getMin() which should return minimum element from the SpecialStack. All these operations of SpecialStack must be O(1). To implement SpecialStack, you should only use standard Stack data structure and no other data structure like arrays, list, etc.

Multi-threading is a process in Java in which two or more threads executes simultaneously for maximum utilization of the CPU.
class SpecialStack:
    def __init__(self, capacity):
        self.stack = []
        self.capacity = capacity

    def push(self, data):
        if len(self.stack) == self.capacity:
            return "Stack is full"
        minimum = data if len(self.stack) == 0 else min(data, self.stack[-1][1])
        self.stack.append((data, minimum))

    def pop(self):
        if len(self.stack) == 0:
            return "Stack is empty"
        return self.stack.pop()[0]

    def getMin(self):
        if len(self.stack) == 0:
            return "Stack is empty"
        return self.stack[-1][1]

    def isEmpty(self):
        return len(self.stack) == 0

    def isFull(self):
        return len(self.stack) == self.capacity
This implementation takes O(1) time for all operations including getMin().

How do you flat an Array numpy?

In NumPy, you can use the ravel function to flatten a multi-dimensional array into a one-dimensional array. For example:
import numpy as np

# Create a 2-dimensional array
array = np.array([[1, 2, 3], [4, 5, 6]])

# Flatten the array
flattened_array = array.ravel()

print(flattened_array)  # Output: [1 2 3 4 5 6]
Alternatively, you can use the flatten method, which returns a copy of the flattened array:
flattened_array = array.flatten()

print(flattened_array)  # Output: [1 2 3 4 5 6]
Both ravel and flatten produce a one-dimensional array that has the same data as the original array, but with the dimensions removed. The difference between the two functions is that ravel returns a flattened array that is a reference to the original array, while flatten returns a copy of the flattened array.

How do you display a tree spirally?

To display a binary tree spirally, you can traverse the tree level by level and reverse the order of nodes at alternate levels. Here's an example implementation in Python:
class SpecialStack:
    def __init__(self, capacity):
        self.stack = []
        self.capacity = capacity

    def push(self, data):
        if len(self.stack) == self.capacity:
            return "Stack is full"
        minimum = data if len(self.stack) == 0 else min(data, self.stack[-1][1])
        self.stack.append((data, minimum))

    def pop(self):
        if len(self.stack) == 0:
            return "Stack is empty"
        return self.stack.pop()[0]

    def getMin(self):
        if len(self.stack) == 0:
            return "Stack is empty"
        return self.stack[-1][1]

    def isEmpty(self):
        return len(self.stack) == 0

    def isFull(self):
        return len(self.stack) == self.capacity
This implementation uses two stacks and alternates between them to traverse the tree in a spiral manner. The variable level is used to keep track of the level of the tree, which determines the order of the nodes in each level. The time complexity of this algorithm is O(n), where n is the number of nodes in the tree.

Encode and Decode a tree.

To encode a tree, you can perform a pre-order traversal of the tree and store the values of each node in a string. For example, in the following tree:
    1
   / \
  2   3
 / \
4   5
The encoded string would be “1 2 4 5 3”.
Here’s an implementation in Python for encoding a tree:
class TreeNode:
    def __init__(self, x):
        self.val = x
        self.left = None
        self.right = None

def serialize(root):
    if not root:
        return "#"
    return str(root.val) + " " + serialize(root.left) + " " + serialize(root.right)
To decode the encoded string, you can reconstruct the tree by reading the values in the string one by one and creating a node for each value. You can use a queue to store the values and traverse the tree in a breadth-first manner.
Here’s an implementation in Python for decoding a tree:
def deserialize(data):
    values = data.split()
    index = 0
    return helper(values, index)

def helper(values, index):
    if values[index] == "#":
        return None
    node = TreeNode(int(values[index]))
    index += 1
    node.left = helper(values, index)
    index += 1
    node.right = helper(values, index)
    return node
The time complexity of both encoding and decoding is O(n), where n is the number of nodes in the tree.

Given an integer n, find the number of structurally unique BSTs possible, of N nodes numbered from 1 to N.

The number of structurally unique BSTs of n nodes can be found using dynamic programming. We can define a recursive formula dp[i] to represent the number of structurally unique BSTs of i nodes, where i ranges from 1 to n.
Here's the formula:
dp[i] = sum(dp[j-1] * dp[i-j] for j in range(1, i+1))
where j is the root node and j-1 and i-j are the number of nodes in the left and right subtrees, respectively. The base case is dp[0]=1 and dp[1]=1.
Here’s an implementation in Python:
def numTrees(n):
    dp = [0] * (n+1)
    dp[0], dp[1] = 1, 1
    for i in range(2, n+1):
        for j in range(1, i+1):
            dp[i] += dp[j-1] * dp[i-j]
    return dp[n]
The time complexity of this solution is O(n^2).

Nagarro Solved

Automata Fixing

      

Popular Category

Hot Topics

Topics

1. TCS Technical Questions
2. CTS Technical Questions
3. Infosys Technical Questions
4. Capgemini Technical Questions
5. IBM Technical Questions
6. Wipro Technical Questions
7. Accenture Technical Questions
8. Deloitte Technical Questions
9. MindTree Technical Questions
10. NTT Data Technical Questions
11. Persistent Technical Questions
12. Hexaware Technical Questions
13. ZOHO Technical Questions
14. HCL Technical Questions
15. Genpact Technical Questions
16. udostres Technical Questions
17. samsung research Technical Questions
18. Media.net Technical Questions
19. Tejas Network Technical Questions
20. Kantar Technical Questions
21. Itron Technical Questions
22. Fractal Analyst Technical Questions
23. Lexmark International Technical Questions
24. Infeneon Technologies Technical Questions
25. Razorpay Technical Questions
26. payu Technical Questions
27. Navi Technical Questions
28. Tata Cliq Technical Questions
29. Grab Technical Questions
30. Schlumberger Technical Questions
31. Latenview Analytics Technical Questions
32. GreayB Technical Questions
33. Tally solution Technical Questions
34. Amagi Technical Questions
35. HFCL Technical Questions
36. Slice Technical Questions
37. Larsen & Turbo Technical Questions
38. Zenser Technical Questions
39. Siemens Technical Questions
40. Exon Movie Technical Questions
41. Gupshup Technical Questions
42. Smart cube Technical Questions
43. Celebal Tech Technical Questions
44. Teg Analytics Technical Questions
45. Commvault Systems Technical Questions
46. Incuture Technical Questions
47. Tiger Technical Questions
48. Bridgei2i Technical Questions
49. code nation Technical Questions
50. DE Show Technical Questions
51. Amazon Technical Questions
52. Flipkart Technical Questions
53. Morgan Stanly Technical Questions
54. duutsche bank Technical Questions
55. textas Technical Questions
56. pwc Technical Questions
57. salesforce Technical Questions
58. optum Technical Questions
59. Nvidia Technical Questions
60. Itc Infotech Technical Questions
61. linkedin Technical Questions
62. Adobe Technical Questions

We Love to Support you

Go through our study material. Your Job is awaiting.

Categories