Join Regular Classroom : Visit ClassroomTech

Latenview Analytics Overall Interview Questions + Coding Solutions – codewindow.in

Hot Topics

Latenview Analytics Solution

Technical Round

Reverse a string

Here’s a simple implementation of a reverse string algorithm in C:
#include <stdio.h>
#include <string.h>

void reverse(char *str) {
    int len = strlen(str);
    int i;
    for (i = 0; i < len / 2; i++) {
        char temp = str[i];
        str[i] = str[len - i - 1];
        str[len - i - 1] = temp;
    }
}

int main() {
    char str[] = "Hello World";
    reverse(str);
    printf("Reversed string: %s\n", str);
    return 0;
}
/*
Reversed string: dlroW olleH
*/
This algorithm uses two pointers, one at the start of the string and one at the end, and swaps the characters at these positions. The process is repeated until the pointers meet in the middle. The strlen function is used to determine the length of the string, and the for loop runs len/2 times to reverse the string.

You are at a position ‘A’ reading a milestone value (xy) which is a two digit and then u travel at a speed of 45kmph and reach point ‘B’ were the new milestone value is (yx) what was the initial value of the first milestone (xy).

If you’re reading the first milestone value (xy) at position A, then travel to position B at a speed of 45 km/h, and read the new milestone value (yx), then (xy) and (yx) represent the same two-digit number.
Therefore, the initial value of the first milestone (xy) is equal to the value of the second milestone (yx).

Given a set of ten people with each listing 5 of their favorite actors along with their personal rating in the scale of 1 to 10 find top 5 pairs among them and write code for the same.

Here is a sample implementation of finding the top 5 pairs of favorite actors among 10 people in Python:
from collections import defaultdict
from heapq import nlargest

def top_5_pairs(people):
    # Create a defaultdict to store the actor pairs and their ratings
    actor_pairs = defaultdict(int)
    
    # Iterate through the people
    for person in people:
        # Get the 5 favorite actors for the person
        favorites = person[:5]
        
        # Iterate through the actor pairs for the person
        for i in range(len(favorites)):
            for j in range(i + 1, len(favorites)):
                # Get the actor pair and the rating
                pair = (favorites[i], favorites[j])
                rating = person[5][i] + person[5][j]
                
                # Add the rating to the actor pair
                actor_pairs[pair] += rating
                
    # Get the top 5 pairs by rating
    top_5 = nlargest(5, actor_pairs, key=actor_pairs.get)
    
    return top_5

people = [
    ("Tom Hanks", "Leonardo DiCaprio", "Robert De Niro", "Brad Pitt", "Al Pacino", [9, 8, 7, 10, 9]),
    ("Tom Cruise", "Leonardo DiCaprio", "Robert De Niro", "Brad Pitt", "Al Pacino", [10, 9, 8, 10, 8]),
    ("Will Smith", "Leonardo DiCaprio", "Robert De Niro", "Brad Pitt", "Al Pacino", [8, 9, 7, 9, 8]),
    ("Jim Carrey", "Leonardo DiCaprio", "Robert De Niro", "Brad Pitt", "Al Pacino", [9, 8, 10, 9, 8]),
    ("Tom Hanks", "Leonardo DiCaprio", "Robert De Niro", "Brad Pitt", "Al Pacino", [9, 8, 7, 10, 9]),
    ("Tom Cruise", "Leonardo DiCaprio", "Robert De Niro", "Brad Pitt", "Al Pacino", [10, 9, 8, 10, 8]),
    ("Will Smith", "Leonardo DiCaprio", "Robert De Niro", "Brad Pitt", "Al Pacino", [8, 9, 7, 9, 8]),
    ("Jim Carrey", "Leonardo DiCaprio", "Robert De Niro", "Brad Pitt", "Al Pacino", [9, 8, 10, 9, 8]),
    ("Tom Hanks", "Leonardo DiCaprio", "Robert De Niro", "Brad Pitt", "Al Pacino", [9, 8, 7, 10, 9]),
    ("Tom Cruise", "Leonardo DiCaprio", "Robert De Niro", "Brad Pitt", "Al Pacino", [10, 9, 8, 10, 8]),
]

print(top_5_pairs(people))
# OUTPUT -[('Leonardo DiCaprio', 'Brad Pitt'), ('Brad Pitt', 'Al Pacino'), ('Robert De Niro', 'Brad Pitt'), ('Leonardo DiCaprio', 'Al Pacino'), ('Leonardo DiCaprio', 'Robert De Niro')]
The output will be the top 5 pairs of favorite actors and their ratings, sorted by rating in descending order.

How much oil is consumed by autos in India?

The exact amount of oil consumed by autos in India is not publicly available, as it is constantly changing based on various factors such as the number of vehicles on the road, driving patterns, and fuel efficiency. However, according to the Ministry of Petroleum & Natural Gas, India’s total petroleum consumption for the year 2020 was 213.0 Million Metric Tonnes (MMT), with a significant portion of that being consumed by the transportation sector, including automobiles.A

Write a code for calculating LCM and GCD.

Here’s a Python implementation to calculate the LCM (Least Common Multiple) and GCD (Greatest Common Divisor) of two numbers:

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def lcm(a, b):
    return a * b // gcd(a, b)

a = 15
b = 20
print("LCM of", a, "and", b, "is", lcm(a, b))
print("GCD of", a, "and", b, "is", gcd(a, b))

#OUTPUT -LCM of 15 and 20 is 60 
#        GCD of 15 and 20 is 5

Tell me about Web Mining?

extracting and analyzing the content of web pages, such as text, images, videos, etc. to gain insights into the topics and trends of the web.
  1. Web Structure Mining: This involves analyzing the structure and relationships of web pages, such as links and hyperlinks, to uncover patterns and connections between different pages.
  2. Web Usage Mining: This involves analyzing the behavior and patterns of web users, such as their browsing history, search queries, and clickstream data, to gain insights into their preferences and behavior.
Web mining is useful for a variety of applications, including search engine optimization, personalized recommendations, e-commerce analysis, market research, and more. By automating the process of extracting and categorizing information from the web, web mining can help businesses and organizations to gain valuable insights into their customers and market trends.

Swap two numbers with 2 variables

#include <bits/stdc++.h>
using namespace std;

int main() {
    int a,b;
    cout<<"Enter the first value for which you need to swap"<<endl;
    cin>>a;
    cout<<"Enter the second value for which you need to swap"<<endl;
    cin>>b;
    a=a-b;
    b=a+b;
    a=b-a;
    cout<<"After swapping the first value becomes: "<<a<<endl;
    cout<<"After swapping the second value becomes: "<<b<<endl;
    
    return 0;
}
/*
OUTPUT - 
Enter the first value for which you need to swap
456
Enter the second value for which you need to swap
965
After swapping the first value becomes: 965
After swapping the second value becomes: 456
*/

If a flower is at the center of pond, and it doubles every day and cover the whole of the pond then in how many days will it cover half of the pond?

To solve this problem, we need to use logarithms.
Let’s assume that the pond is fully covered on the nth day. So, on the n-1th day, the flower covered half of the pond.
Therefore, on the n-1th day, the size of the flower was (1/2) * size of pond.
We know that the size of the flower doubles every day, so the size of the flower on day n-2 was (1/2) * (1/2) * size of pond.
Continuing this logic, we can say that the size of the flower on day n-k was (1/2)^k * size of pond.
So, we need to find the value of k such that (1/2)^k = 1/2.
Taking log base 2 on both sides, we get:
k = log base 2 (1/2)
Therefore, the flower will cover half of the pond after log base 2 (1/2) days.

Tell me your expertise Domain?

Tell about the domain you have expertise in and mention why you choose that domain and what do you like the most about that domain.

Bubble sort using C++.

Here is an implementation of bubble sort in C++:

#include <iostream>
using namespace std;

void bubbleSort(int arr[], int n) {
  for (int i = 0; i < n - 1; i++) {
    for (int j = 0; j < n - i - 1; j++) {
      if (arr[j] > arr[j + 1]) {
        int temp = arr[j];
        arr[j] = arr[j + 1];
        arr[j + 1] = temp;
      }
    }
  }
}

void printArray(int arr[], int n) {
  for (int i = 0; i < n; i++) {
    cout << arr[i] << " ";
  }
  cout << endl;
}

int main() {
  int arr[] = {64, 34, 25, 12, 22, 11, 90};
  int n = sizeof(arr) / sizeof(arr[0]);

  cout << "Original array: ";
  printArray(arr, n);

  bubbleSort(arr, n);

  cout << "Sorted array: ";
  printArray(arr, n);

  return 0;
}
/*
/tmp/hAxDocDZn3.o
Original array: 64 34 25 12 22 11 90 
Sorted array: 11 12 22 25 34 64 90 
*/
In this implementation, the bubbleSort function takes an array arr and its size n as input, and sorts the elements of the array in ascending order using the bubble sort algorithm. The printArray function takes an array and its size as input, and prints the elements of the array. The main function initializes an array, and calls the bubbleSort and printArray functions to sort and print the array, respectively.

Think if you are a cricket bat retailer, what would be your estimate for investment in your locality range?

As a cricket bat retailer, there are several factors to consider when estimating investment costs in your local market. These factors include:
  1. Market research: Conduct a market research to understand the demand for cricket bats in your local area and identify your target customer base.
  2. Location: The location of your retail store is crucial, as it can significantly impact your sales and expenses. Choose a location that is easily accessible to your target customers.
  3. Inventory: You will need to purchase inventory, including cricket bats, batting gloves, and other accessories. The cost of inventory will depend on the brand and quality of products you want to sell.
  4. Store setup: You will need to invest in store fixtures, signage, and other setup costs to create a welcoming and professional shopping environment for your customers.
  5. Advertising and marketing: You will need to invest in advertising and marketing efforts to promote your store and build awareness among your target customers.
  6. Operating expenses: You will need to factor in ongoing operating expenses such as rent, utilities, insurance, and employee salaries.
Based on these factors, you can create a rough estimate of your investment costs and compare it against the potential revenue to determine if starting a cricket bat retail business in your local area is feasible. It is always advisable to consult with a financial advisor to get a more accurate estimate and to help plan your business finances.

Nagarro Solved

Automata Fixing

      

We Love to Support you

Go through our study material. Your Job is awaiting.

Recent Posts
Categories