Hewlett Packard Enterprise
20+ HMEL's Guru Gobind Singh Petroleum Refinery Interview Questions and Answers
Q1. Find the Duplicate Number Problem Statement
Given an integer array 'ARR' of size 'N' containing numbers from 0 to (N - 2). Each number appears at least once, and there is one number that appears twice. Your tas...read more
Find the duplicate number in an array of integers from 0 to N-2.
Iterate through the array and keep track of the frequency of each number using a hashmap.
Return the number with a frequency greater than 1 as the duplicate number.
Alternatively, use Floyd's Tortoise and Hare algorithm to find the duplicate number in O(N) time and O(1) space.
Q2. Count Inversions Problem Statement
Given an integer array ARR
of size N
, your task is to find the total number of inversions that exist in the array.
An inversion is defined for a pair of integers in the array ...read more
Count the total number of inversions in an integer array.
Iterate through the array and for each pair of elements, check if the conditions for inversion are met.
Use a nested loop to compare each pair of elements efficiently.
Keep a count of the inversions found and return the total count at the end.
Q3. Remove Occurrences of Character from String
Given a string str
and a character X
, write a function to remove all occurrences of X
from the string.
If the character X
does not exist in the input string, the stri...read more
Create a function to remove all occurrences of a given character from a string.
Iterate through the string and build a new string excluding the specified character.
Use string manipulation functions to achieve the desired result.
Handle the case where the character does not exist in the string.
Return the modified string as the output.
Q4. Remove Character from String Problem Statement
Given a string str
and a character 'X', develop a function to eliminate all instances of 'X' from str
and return the resulting string.
Input:
The first line contai...read more
Develop a function to remove all instances of a given character from a string.
Iterate through the string and only add characters that are not equal to the given character to a new string.
Return the new string as the result.
Handle edge cases like empty string or character not found in the string.
Example: Input 'hello world' and 'o', output 'hell wrld'.
Q5. Character Frequency Problem Statement
You are given a string 'S' of length 'N'. Your task is to find the frequency of each character from 'a' to 'z' in the string.
Example:
Input:
S : abcdg
Output:
1 1 1 1 0 0 ...read more
The task is to find the frequency of each character from 'a' to 'z' in a given string.
Create an array of size 26 to store the frequency of each character from 'a' to 'z'.
Iterate through the given string and increment the count of each character in the array.
Print the array of frequencies as the output for each test case.
Q6. Middle of a Linked List
You are given the head node of a singly linked list. Your task is to return a pointer pointing to the middle of the linked list.
If there is an odd number of elements, return the middle ...read more
Return the middle element of a singly linked list, or the one farther from the head node in case of even number of elements.
Traverse the linked list with two pointers, one moving twice as fast as the other
When the fast pointer reaches the end, the slow pointer will be at the middle
Return the element pointed to by the slow pointer
Q7. Subarray With Given Sum Problem Statement
Given an array ARR
of N integers and an integer S, determine if there exists a contiguous subarray within the array with a sum equal to S. If such a subarray exists, re...read more
Given an array of integers, find a contiguous subarray with a given sum.
Iterate through the array while keeping track of the current sum and start index.
Use a hashmap to store the sum and its corresponding index.
If the current sum - target sum exists in the hashmap, return the indices.
Handle edge cases like when the target sum is 0 or when no subarray is found.
Q8. Maximum Subarray Sum Problem Statement
Given an array arr
of length N
consisting of integers, find the sum of the subarray (including empty subarray) with the maximum sum among all subarrays.
Explanation:
A sub...read more
Find the sum of the subarray with the maximum sum among all subarrays in a given array.
Iterate through the array and keep track of the maximum sum subarray seen so far.
Use Kadane's algorithm to efficiently find the maximum subarray sum.
Handle cases where all elements are negative or array is empty.
Example: For input arr = [-2, 1, -3, 4, -1], the maximum subarray sum is 4.
Q9. Intersection of Linked List Problem
You are provided with two singly linked lists containing integers, where both lists converge at some node belonging to a third linked list.
Your task is to determine the data...read more
Find the node where two linked lists merge, return -1 if no merging occurs.
Traverse both lists to find their lengths and the difference in lengths
Move the pointer of the longer list by the difference in lengths
Traverse both lists simultaneously until they meet at the merging point
Method overloading is having multiple methods in the same class with the same name but different parameters. Method overriding is redefining a method in a subclass with the same signature as in the superclass.
Method overloading allows multiple methods with the same name but different parameters in the same class.
Method overriding involves redefining a method in a subclass with the same signature as in the superclass.
Method overloading is resolved at compile time based on the ...read more
Q11. How well can you adapt when there is a change in technology used for a project? Explain your learning initiatives and processes that can be undertaken to ensure the knowledge transfer is done smoothly as expect...
read moreI am highly adaptable to changes in technology and have a structured learning process to ensure smooth knowledge transfer.
I stay up-to-date with the latest technology trends and advancements
I am open to learning new technologies and tools
I have a structured learning process that involves researching, reading documentation, and practicing
I collaborate with team members to share knowledge and learn from each other
I attend conferences and workshops to learn about new technologie...read more
Static linking includes all library modules in the executable file, while dynamic linking loads libraries at runtime.
Static linking includes all library modules in the executable file, increasing its size.
Dynamic linking loads libraries at runtime, reducing the size of the executable file.
Static linking results in faster startup time, while dynamic linking allows for easier updates to libraries.
Examples of static linking include linking libraries during compilation, while dyn...read more
Inline functions are actual functions while macros are preprocessor directives in C++.
Inline functions are actual functions defined with the 'inline' keyword, while macros are preprocessor directives that are replaced before compilation.
Inline functions provide type checking and scope resolution, while macros do not.
Inline functions can have multiple lines of code and can access variables in the scope they are called from, while macros are limited to a single line and do not ...read more
UNION combines and removes duplicate rows, UNION ALL combines without removing duplicates.
UNION combines the result sets of two or more SELECT statements into a single result set
UNION removes duplicate rows from the result set
UNION ALL combines the result sets without removing duplicates
UNION is slower than UNION ALL as it requires additional processing to remove duplicates
Use UNION when you want to combine and remove duplicates, use UNION ALL when you want to combine without...read more
Multitasking involves executing multiple tasks simultaneously, while multiprogramming involves running multiple programs on a single processor.
Multitasking allows multiple tasks to run concurrently on a single processor, switching between them quickly.
Multiprogramming involves loading multiple programs into memory and executing them concurrently, utilizing idle CPU time efficiently.
Examples of multitasking include running multiple applications on a computer at the same time, ...read more
A process is an executing instance of a program, while a program is a set of instructions stored in the computer's memory.
A program is a static set of instructions stored on disk, while a process is a dynamic instance of those instructions being executed in memory.
Multiple processes can be running the same program simultaneously, each with its own memory space and resources.
Processes have their own unique process ID (PID) and can communicate with each other through inter-proc...read more
Virtual functions in C++ allow a function to be overridden in a derived class, enabling polymorphic behavior.
Virtual functions are declared in a base class with the 'virtual' keyword.
They are overridden in derived classes to provide specific implementations.
They enable polymorphism, allowing objects of different derived classes to be treated as objects of the base class.
Example: class Animal { virtual void makeSound() { cout << 'Animal sound'; } }; class Dog : public Animal {...read more
Q18. Please brief me about the ITIL framework and how it helps in the application management practices.
ITIL is a framework for IT service management that helps in application management practices.
ITIL stands for Information Technology Infrastructure Library.
It provides a set of best practices for IT service management.
ITIL helps in improving the quality of IT services and reducing costs.
It includes processes for incident management, problem management, change management, and more.
ITIL helps in aligning IT services with business needs.
In application management, ITIL helps in en...read more
A process is an instance of a program, while a thread is a unit of execution within a process.
A process has its own memory space, while threads share the same memory space.
Processes are independent and isolated, while threads can communicate and share resources.
Creating a new process is more resource-intensive than creating a new thread.
Processes have their own program counter, while threads share the same program counter.
Examples: Running multiple instances of a web browser ...read more
A linker error in C++ occurs when the linker is unable to resolve references to functions or variables during the linking phase of compilation.
Linker errors occur when there are missing definitions for functions or variables that are referenced in the code.
Common causes of linker errors include forgetting to define a function that is declared, or not including the necessary library or object files.
Example: If a function 'foo()' is declared in a header file but not defined in ...read more
Views provide a virtual representation of data, offering advantages such as simplifying complex queries, enhancing security, and improving performance.
Views simplify complex queries by predefining commonly used joins, filters, and aggregations.
Views enhance security by allowing users to access only specific columns or rows of a table.
Views improve performance by storing the results of complex queries, reducing the need for repetitive calculations.
Views can be used to hide sen...read more
ARP stands for Address Resolution Protocol, used to map IP addresses to MAC addresses in a local network.
ARP is used to find the MAC address of a device based on its IP address
It operates at the data link layer of the OSI model
ARP requests are broadcasted to all devices on the local network
Example: When a device wants to communicate with another device on the same network, it uses ARP to find the MAC address of the destination device
Q23. Design a classroom management system
A classroom management system to track student attendance, grades, assignments, and communication with parents.
Track student attendance using RFID cards or biometric scanners
Record grades for each assignment and calculate overall grade
Manage assignments and deadlines with notifications for students
Enable communication between teachers, students, and parents through messaging system
More about working at Hewlett Packard Enterprise
Interview Process at HMEL's Guru Gobind Singh Petroleum Refinery
Top Software Developer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month