Amdocs
60+ Semco Maritime Interview Questions and Answers
Q1. Maximum Sum Increasing Subsequence of Length K Problem Statement
You are given an array NUMS
consisting of N integers and an integer K. Your task is to determine the maximum sum of an increasing subsequence of ...read more
Q2. First Unique Character in a String Problem Statement
Given a string STR
consisting of lowercase English letters, identify the first non-repeating character in the string and return it. If no such character exis...read more
Q3. Implement Atoi Function
You have a string 'STR' of length 'N'. Your task is to implement the atoi function, which converts the string into an integer. If the string does not contain any numbers, the function sh...read more
Q4. Subarray with Equal Occurrences Problem Statement
You are provided with an array/list ARR
of length N
containing only 0s and 1s. Your goal is to determine the number of non-empty subarrays where the number of 0...read more
Q5. Palindrome String Validation
Determine if a given string 'S' is a palindrome, considering only alphanumeric characters and ignoring spaces and symbols.
Note:
The string 'S' should be evaluated in a case-insensi...read more
Q6. Pythagorean Triplets Detection
Determine if an array contains a Pythagorean triplet by checking whether there are three integers x, y, and z such that x2 + y2 = z2 within the array.
Input:
The first line contai...read more
Q7. Fibonacci Number Verification
Identify if the provided integer 'N' is a Fibonacci number.
A number is termed as a Fibonacci number if it appears in the Fibonacci sequence, where each number is the sum of the tw...read more
Q8. K - Sum Path In A Binary Tree
Given a binary tree where each node contains an integer value, and a value 'K', your task is to find all the paths in the binary tree such that the sum of the node values in each p...read more
Q9. Nth Fibonacci Number Problem Statement
Calculate the Nth term in the Fibonacci sequence, where the sequence is defined as follows: F(n) = F(n-1) + F(n-2)
, with initial conditions F(1) = F(2) = 1
.
Input:
The inp...read more
Q10. All Prime Numbers Problem Statement
Given an integer 'N', your task is to print all the prime numbers that lie within the range from 2 to 'N' (inclusive).
Input:
Integer N
Output:
Prime numbers printed on separ...read more
Q11. Reverse Stack with Recursion
Reverse a given stack of integers using recursion. You must accomplish this without utilizing extra space beyond the internal stack space used by recursion. Additionally, you must r...read more
Q12. Nth Fibonacci Number Problem
Calculate the Nth term in the Fibonacci sequence using the formula: F(n) = F(n-1) + F(n-2)
where F(1) = F(2) = 1
.
Given a number N, determine the Nth Fibonacci number.
Input:
N
Outp...read more
Q13. Priority Queue Implementation
Ninja is tasked with implementing a priority queue using the Heap data structure. Since Ninja is busy with tournament preparations, your help is requested to complete this task.
Pr...read more
Q14. What is right outer join and it's use in real world scenario
Right outer join is a type of join operation that returns all the rows from the right table and the matching rows from the left table.
Right outer join is denoted by the RIGHT JOIN keyword in SQL.
It is used to combine rows from two tables based on a related column.
In the result set, unmatched rows from the right table will have NULL values for the columns of the left table.
A real-world scenario for using a right outer join is when analyzing customer data and sales data. The ri...read more
Q15. How to convert a string containing a number into integer without using inbuilt function?
Convert string to integer without using inbuilt function
Iterate through each character and multiply by 10 and add the integer value of the character
Use ASCII values to convert character to integer
Handle negative numbers separately
Q21. What is recursion?Explain it graphically?How compiler executed recursion?
Recursion is a process in which a function calls itself repeatedly until a base condition is met.
Recursion involves breaking down a problem into smaller subproblems and solving them recursively.
It uses a stack to keep track of function calls and their parameters.
Examples include factorial, Fibonacci sequence, and binary search.
Compiler executes recursion by allocating memory for each function call and storing the return address and local variables on the stack.
It then pops th...read more
Q25. What is python and constructer ,arrays,data structures
Python is a high-level programming language known for its simplicity and readability. Constructors are special methods used to initialize objects in classes.
Python is a versatile programming language used for web development, data analysis, artificial intelligence, and more.
Constructors in Python are special methods with the __init__() function that initialize objects when they are created.
Arrays in Python are data structures that can hold multiple values of the same type. Th...read more
Q26. Swap two character variables without using third
Swapping two character variables without using third
Use XOR operator to swap two variables without using third variable
Assign the XOR of both variables to the first variable
Assign the XOR of the first variable and second variable to the second variable
Q29. Write any program of recursion and explain it using stack frames?
A program demonstrating recursion using factorial function.
Recursion is a technique where a function calls itself.
Factorial function is a classic example of recursion.
Each recursive call creates a new stack frame.
The base case is when the input is 1, and the function returns 1.
The final result is the product of all the recursive calls.
Example: factorial(5) = 5 * factorial(4) = 5 * 4 * factorial(3) = ... = 5 * 4 * 3 * 2 * 1 = 120.
Q31. Difference between Primary key and Unique key
Primary key uniquely identifies a record in a table, while Unique key ensures uniqueness of a column.
Primary key can't have null values, Unique key can have one null value
A table can have only one Primary key, but multiple Unique keys
Primary key is automatically indexed, Unique key is not necessarily indexed
Q32. which data structure is used in recursion?
The data structure used in recursion is a stack.
Recursion uses a stack data structure to keep track of function calls.
Each time a function is called, its parameters and local variables are pushed onto the stack.
When the function returns, the values are popped off the stack.
This allows the program to keep track of where it is in the recursive process.
Examples of recursive algorithms that use a stack include depth-first search and quicksort.
Q34. Write a program to check string is pallindrome or not
Program to check if a string is a palindrome or not.
Remove all spaces and convert to lowercase for case-insensitive comparison.
Compare the first and last characters, then move towards the center until all characters have been compared.
If all characters match, the string is a palindrome.
If any characters do not match, the string is not a palindrome.
Q35. What is a friend function
A friend function is a non-member function that has access to the private and protected members of a class.
Declared inside the class but defined outside the class scope
Can access private and protected members of the class
Not a member of the class but has access to its private members
Used to allow external functions to access and modify private data of a class
Can be declared as a friend in another class
Q36. What is garbage collection in java
Garbage collection in Java is an automatic memory management process.
It frees up memory by removing objects that are no longer in use.
It is performed by the JVM in the background.
It helps prevent memory leaks and improves performance.
There are different types of garbage collectors in Java, such as Serial, Parallel, CMS, and G1.
Example: int[] arr = new int[1000]; arr = null; // Garbage collector will remove the array from memory
Q37. Addition and Deletion of a node in binary tree?
Addition and Deletion of a node in binary tree
For addition, traverse the tree to find the appropriate position and add the new node as a leaf
For deletion, find the node to be deleted and replace it with its successor or predecessor
In case of deletion, if the node has two children, find the inorder successor and replace it with the node to be deleted
Q39. Definition of atoi function of C
atoi function converts a string to an integer in C.
The function takes a string as input and returns an integer.
Leading white spaces are ignored.
If the string contains non-numeric characters, the function stops conversion and returns the converted value.
The function returns 0 if the input string is not a valid integer.
Example: atoi('123') returns 123.
Q40. A program to print star pattern
A program to print star pattern
Use nested loops to print the pattern
The outer loop controls the number of rows
The inner loop controls the number of stars to be printed in each row
Use print() or println() function to print the stars
Q42. What is refrential integrity
Refrential integrity ensures that relationships between tables in a database remain consistent.
It is a database concept that ensures that foreign key values in one table match the primary key values in another table.
It prevents orphaned records in a database.
It maintains data consistency and accuracy.
For example, if a customer record is deleted, all related orders for that customer should also be deleted.
It is enforced through constraints such as foreign key constraints.
Q43. 2.what is singleton pattern
Singleton pattern is a design pattern that restricts the instantiation of a class to one object.
Used when only one instance of a class is needed throughout the application
Provides a global point of access to the instance
Implemented using a private constructor and a static method to return the instance
Example: Database connection, Logger, Configuration settings
Q44. Real time examples of Data structures?
Data structures are used to organize and store data in a computer program.
Arrays - used to store a collection of elements of the same data type
Linked Lists - used to store a collection of elements where each element points to the next element
Stacks - used to store a collection of elements where the last element added is the first element removed
Queues - used to store a collection of elements where the first element added is the first element removed
Trees - used to store hiera...read more
Q45. Which programming languages do you know.
I know multiple programming languages including Java, Python, and C++.
Java
Python
C++
Q46. 3.what is static variable
Static variable is a variable that retains its value even after the function execution is completed.
Declared with static keyword
Memory is allocated once and shared among all instances of the class or function
Can be accessed without creating an object of the class
Q47. Triggers and their types
Triggers are database objects that are automatically executed in response to certain events.
Triggers can be used to enforce business rules, audit changes, or replicate data.
There are two types of triggers: DML triggers and DDL triggers.
DML triggers are fired in response to DML statements (INSERT, UPDATE, DELETE).
DDL triggers are fired in response to DDL statements (CREATE, ALTER, DROP).
Q48. Libraries and packages in python
Libraries and packages in Python are reusable collections of code that provide functionality to perform specific tasks.
Libraries and packages help in reducing the amount of code that needs to be written from scratch
Popular libraries in Python include NumPy for numerical computing, Pandas for data manipulation, and Matplotlib for data visualization
Packages can be installed using package managers like pip or conda
Q49. Run time polymorphism in C++
Run time polymorphism is the ability of a program to determine the object type at runtime and call the appropriate method.
It is achieved through virtual functions and dynamic binding.
Allows for more flexible and extensible code.
Example: a base class Animal with virtual function makeSound() and derived classes Dog and Cat that override makeSound().
At runtime, if an Animal pointer points to a Dog object, calling makeSound() will execute the Dog's implementation.
Q50. Five linux commands you know
Five commonly used Linux commands
ls - list directory contents
cd - change directory
mkdir - make directory
rm - remove files or directories
grep - search for a pattern in a file
Q51. Write a query for delete
Query for deleting data from a database table.
Use the DELETE statement followed by the table name.
Add a WHERE clause to specify the condition for deleting specific rows.
Be careful when deleting data as it cannot be recovered.
Example: DELETE FROM customers WHERE customer_id = 1234;
Q52. Explain time complexity
Time complexity refers to the amount of time taken by an algorithm to run as the input size increases.
It measures the efficiency of an algorithm.
It is usually expressed in Big O notation.
An algorithm with a lower time complexity is more efficient than one with a higher time complexity.
Q53. Count the number of vowels in a string
Count the number of vowels in a given string
Iterate through each character in the string and check if it is a vowel (a, e, i, o, u)
Maintain a count of vowels encountered
Return the total count of vowels in the string
Q54. Write a code for copy constructor
A copy constructor is a special type of constructor which creates a new object as a copy of an existing object.
Ensure the copy constructor has the same signature as the default constructor.
Allocate memory for the new object and copy the values from the existing object.
Handle deep copy vs shallow copy based on the object's data types.
Q55. What is a copy constructor
A copy constructor is a special type of constructor in object-oriented programming that creates a new object as a copy of an existing object.
Creates a new object by copying the attributes of an existing object
Used to initialize a new object with the values of an existing object
Helps in creating deep copies of objects to avoid shallow copy issues
Q56. Explain Oops in java?
Object-oriented programming paradigm in Java focusing on objects and classes.
OOPs stands for Object-Oriented Programming.
It focuses on creating objects that interact with each other through classes.
Key principles include Inheritance, Encapsulation, Polymorphism, and Abstraction.
Example: Class Car { String color; void start() { //code here } }
Example: Car myCar = new Car(); myCar.color = 'red'; myCar.start();
Q57. Collection framework in java?
Collection framework in Java provides a set of interfaces and classes to store and manipulate groups of objects.
Includes interfaces like List, Set, and Map
Classes like ArrayList, LinkedList, HashSet, and HashMap implement these interfaces
Provides methods for adding, removing, and accessing elements in collections
Q58. 1. CountingSubstring in array
Count the number of occurrences of a specific substring in an array of strings.
Iterate through each string in the array and use a function to count occurrences of the substring.
Use a loop to go through each character in the string and check for matches with the substring.
Keep a count variable to track the number of occurrences found.
Q59. joins and their use.
Joins are used in databases to combine rows from two or more tables based on a related column between them.
Joins are used to retrieve data from multiple tables based on a related column.
Common types of joins include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN.
INNER JOIN returns rows when there is at least one match in both tables.
LEFT JOIN returns all rows from the left table and the matched rows from the right table.
RIGHT JOIN returns all rows from the right table and t...read more
Q60. Detect cycle in LinkedList
Detect cycle in LinkedList by using Floyd's Tortoise and Hare algorithm.
Use two pointers, slow and fast, to traverse the LinkedList.
If there is a cycle, the fast pointer will eventually meet the slow pointer.
Initialize slow and fast pointers at the head of the LinkedList.
Move slow pointer by one step and fast pointer by two steps.
If fast pointer reaches the end of the LinkedList, there is no cycle.
Top HR Questions asked in Semco Maritime
Interview Process at Semco Maritime
Top Associate Software Engineer Interview Questions from Similar Companies
Reviews
Interviews
Salaries
Users/Month