Add office photos
Engaged Employer

Oracle

3.7
based on 5.2k Reviews
Video summary
Filter interviews by

80+ Sunny Industries Interview Questions and Answers

Updated 19 Sep 2024
Popular Designations

Q1. Minimum Cost to Connect All Points Problem Statement

Given an array COORDINATES representing the integer coordinates of some points on a 2D plane, determine the minimum cost required to connect all points. The ...read more

Ans.

The problem involves finding the minimum cost to connect all points on a 2D plane using Manhattan distance.

  • Create a function that calculates the Manhattan distance between two points.

  • Implement a function to find the minimum spanning tree to connect all points.

  • Consider using Prim's or Kruskal's algorithm for finding the minimum spanning tree.

  • Ensure that all points are connected with one simple path only.

View 1 answer

Q2. Puzzle: – Two persons X and Y are sitting side by side with a coin in each’s hand. The game is to simultaneously flip the coin till anyone wins. Player X will win if he gets a consecutive HEAD, TAIL however Y w...

read more
Ans.

The game is not fair.

  • Player X has a higher chance of winning as they only need to get a consecutive HEAD, TAIL.

  • Player Y needs to get a consecutive HEAD, HEAD which is less likely to occur.

  • The probability of Player X winning is higher than Player Y winning.

Add your answer

Q3. Count Subsequences Problem Statement

Given an integer array ARR of size N, your task is to find the total number of subsequences in which all elements are equal.

Explanation:

A subsequence of an array is derive...read more

Ans.

Count the total number of subsequences in which all elements are equal in an integer array.

  • Iterate through the array and count the frequency of each element.

  • Calculate the total number of subsequences for each element using the formula (frequency * (frequency + 1)) / 2.

  • Sum up the total number of subsequences for all elements and return the result modulo 10^9 + 7.

Add your answer

Q4. Remove the Kth Node from the End of a Linked List

You are given a singly Linked List with 'N' nodes containing integer data and an integer 'K'. Your task is to delete the Kth node from the end of this Linked Li...read more

Ans.

Remove the Kth node from the end of a singly linked list given the position 'K'.

  • Traverse the list to find the length 'N' of the linked list.

  • Calculate the position from the beginning as 'N - K + 1'.

  • Delete the node at the calculated position from the beginning.

Add your answer
Discover Sunny Industries interview dos and don'ts from real experiences

Q5. In a bag you have 20 black balls and 16 red balls.When you take out 2 black balls you take another white ball.If you take 2 white balls then you take out 1 black ball and if balls are of different color you tak...

read more
Ans.

The last ball that will be left is black.

  • When you take out 2 black balls, you take another white ball.

  • If you take 2 white balls, you take out 1 black ball.

  • If balls are of different color, you take out another black ball.

  • Since there are more black balls initially, the last ball will be black.

Add your answer

Q6. 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

Ans.

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.

Add your answer
Are these interview questions helpful?

Q7. Palindromic Substrings Problem Statement

Given a string S, your task is to return all distinct palindromic substrings of the given string in alphabetical order.

Explanation:

A string is considered a palindrome ...read more

Ans.

Return all distinct palindromic substrings of a given string in alphabetical order.

  • Iterate through all possible substrings of the given string

  • Check if each substring is a palindrome

  • Store distinct palindromic substrings in alphabetical order

Add your answer

Q8. Find All Occurrences in Matrix

You are provided with a matrix of characters, CHARACTER_MATRIX of size M x N, and a string WORD. Your goal is to locate and display all occurrences of the string within the matrix...read more

Ans.

The goal is to find all occurrences of a given string in a matrix in all eight possible directions.

  • Iterate through each cell in the matrix and check for the starting character of the word.

  • For each starting character found, check in all eight directions for the complete word.

  • Keep track of the coordinates of each character in the word for each occurrence.

  • Print the coordinates of each character for each occurrence found.

  • If no occurrences are found, output 'No match found'.

Add your answer
Share interview questions and help millions of jobseekers 🌟

Q9. LCA of Binary Tree Problem Statement

You are given a binary tree consisting of distinct integers and two nodes, X and Y. Your task is to find and return the Lowest Common Ancestor (LCA) of these two nodes.

The ...read more

Ans.

Find the Lowest Common Ancestor (LCA) of two nodes in a binary tree.

  • Traverse the binary tree to find the paths from the root to nodes X and Y.

  • Compare the paths to find the last common node, which is the LCA.

  • Handle cases where one node is an ancestor of the other.

  • Consider edge cases like when X or Y is the root node.

  • Implement a recursive or iterative solution to find the LCA efficiently.

Add your answer

Q10. Partition Equal Subset Sum Problem

Given an array ARR consisting of 'N' positive integers, determine if it is possible to partition the array into two subsets such that the sum of the elements in both subsets i...read more

Ans.

The task is to determine if it is possible to partition an array into two subsets with equal sum.

  • Iterate through all possible subsets of the array using recursion.

  • Keep track of the sum of elements in each subset.

  • Check if the sum of elements in both subsets is equal.

Add your answer

Q11. 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

Ans.

Return the middle element of a singly linked list, or the one farther from the head if there are even 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

  • If there are even elements, return the one that is farther from the head node

  • Handle edge cases like linked list of size 1 or no midpoint existing

Add your answer

Q12. Valid Parentheses Problem Statement

Given a string 'STR' consisting solely of the characters “{”, “}”, “(”, “)”, “[” and “]”, determine if the parentheses are balanced.

Input:

The first line contains an integer...read more
Ans.

The task is to determine if a given string consisting of parentheses is balanced or not.

  • Iterate through each character in the string and use a stack to keep track of opening parentheses

  • If an opening parenthesis is encountered, push it onto the stack

  • If a closing parenthesis is encountered, check if it matches the top of the stack. If not, the string is not balanced

  • If all parentheses are matched correctly and the stack is empty at the end, the string is balanced

Add your answer

Q13. Heap Sort Problem Statement

Your task is to sort an array of integers in non-decreasing order using the Heap Sort algorithm.

Input:

The first line contains an integer 'T' denoting the number of test cases.
Each...read more
Ans.

Heap Sort algorithm is used to sort an array of integers in non-decreasing order.

  • Implement Heap Sort algorithm to sort the array in non-decreasing order.

  • Use a max heap to sort the array in ascending order.

  • Time complexity of Heap Sort is O(n log n).

Add your answer

Q14. Merge K Sorted Arrays Problem Statement

Given 'K' different arrays that are individually sorted in ascending order, merge all these arrays into a single array that is also sorted in ascending order.

Input

The f...read more
Ans.

Merge K sorted arrays into a single sorted array.

  • Create a min heap to store the first element of each array along with the array index.

  • Pop the root of the heap (smallest element) and add it to the result array.

  • If the array from which the element was taken has more elements, add the next element to the heap.

  • Repeat until all elements are processed.

  • Time complexity: O(N log K) where N is the total number of elements and K is the number of arrays.

Add your answer

Q15. Construct Tree from Preorder Traversal

Given a list of integers pre[] of size n, representing the preorder traversal of a special binary tree where each node has 0 or 2 children, and a boolean array isLeaf[] in...read more

Ans.

Construct a binary tree from preorder traversal and leaf node information.

  • Create a binary tree using preorder traversal and leaf node information

  • Use recursion to build the tree

  • Identify leaf nodes based on the isLeaf array

  • Handle multiple test cases separately

Add your answer

Q16. Design a website similar to bookmyshow.com for booking cinema tickets but it must be for a single location only which can have multiple theatres in it. In this he wanted me to design a basic rough GUI, relevant...

read more
Ans.

Design a website similar to bookmyshow.com for booking cinema tickets for a single location with multiple theatres.

  • Design a user-friendly GUI with options for advance booking, user login, user registration, movie rating, and saving card details.

  • Create relevant database tables to store information about movies, theatres, bookings, user details, and card details.

  • Link the GUI to the database to enable data flow and retrieval.

  • Implement features like advance booking, where users c...read more

Add your answer

Q17. Anagram Pairs Verification Problem

Your task is to determine if two given strings are anagrams of each other. Two strings are considered anagrams if you can rearrange the letters of one string to form the other...read more

Ans.

Determine if two strings are anagrams of each other by checking if they have the same characters in different order.

  • Create character frequency maps for both strings and compare them.

  • Sort both strings and compare them.

  • Use a hash table to store character counts and check if they are equal for both strings.

Add your answer

Q18. Matrix Transpose Problem Statement

Given a matrix MAT, your task is to return the transpose of the matrix. The transpose of a matrix is obtained by converting rows into columns and vice versa. Specifically, the...read more

Ans.

Transpose a given matrix by switching rows and columns.

  • Iterate through the matrix and swap elements at [i][j] with [j][i].

  • Create a new matrix to store the transposed values.

  • Ensure the dimensions of the transposed matrix are switched from the original matrix.

Add your answer

Q19. Infix to Postfix Conversion

You are provided with a string EXP which represents a valid infix expression. Your task is to convert this given infix expression into a postfix expression.

Explanation:

An infix exp...read more

Ans.

Convert a given infix expression to a postfix expression.

  • Use a stack to keep track of operators and operands

  • Follow the rules of precedence for operators

  • Convert the infix expression to postfix using the stack

  • Handle parentheses by pushing them onto the stack and popping when necessary

Add your answer

Q20. Subarray Challenge: Largest Equal 0s and 1s

Determine the length of the largest subarray within a given array of 0s and 1s, such that the subarray contains an equal number of 0s and 1s.

Input:

Input begins with...read more

Ans.

Find the length of the largest subarray with equal number of 0s and 1s in a given array.

  • Iterate through the array and maintain a count of 0s and 1s encountered so far.

  • Store the count difference in a hashmap with the index as the key.

  • If the same count difference is encountered again, the subarray between the two indices has equal 0s and 1s.

Add your answer

Q21. Merge Two Sorted Linked Lists Problem Statement

You are provided with two sorted linked lists. Your task is to merge them into a single sorted linked list and return the head of the combined linked list.

Input:...read more

Ans.

Merge two sorted linked lists into a single sorted linked list with linear time complexity and constant space usage.

  • Iterate through both linked lists simultaneously, comparing elements and merging them into a new linked list

  • Update the pointers of the new linked list as you merge elements from the two input linked lists

  • Ensure to handle cases where one linked list is empty or both linked lists are empty

  • Maintain the sorted order while merging the elements from the two linked lis...read more

Add your answer

Q22. Search in a Row-wise and Column-wise Sorted Matrix Problem Statement

You are given an N * N matrix of integers where each row and each column is sorted in increasing order. Your task is to find the position of ...read more

Ans.

Given a sorted N * N matrix, find the position of a target integer X.

  • Iterate through each row and column to search for the target integer

  • Utilize the sorted nature of the matrix to optimize the search process

  • Return the position of the target integer if found, else return -1 -1

Add your answer

Q23. Provided a string a character and a count, you have to print the string after the specified character has occurred count number of times. Ex: String: “This is demo string” Character: ‘i’ Count: 3 Output: “ng” H...

read more
Ans.

The program prints the substring after a specified character has occurred a certain number of times in a given string.

  • Iterate through the string to find the specified character.

  • Keep track of the count of occurrences of the character.

  • Once the count reaches the specified count, extract the substring after that position.

  • Handle corner cases such as when the character is not in the string or when it doesn't occur the specified number of times.

Add your answer

Q24. There N rooms in a hotel so customers will check-in and check-out a rooms simultaneously so which type of data structure you implement and it should be efficient and extension of this prebooking will also happe...

read more
Ans.

To efficiently manage room bookings and prebookings in a hotel, a priority queue data structure can be implemented.

  • A priority queue can be used to prioritize room bookings based on check-in dates.

  • When a customer checks out, the room becomes available and can be assigned to the next customer in the priority queue.

  • Prebookings can be stored separately and checked against the availability of rooms before assigning them to customers.

  • The priority queue can be implemented using a bi...read more

Add your answer

Q25. Greatest Common Divisor Problem Statement

You are tasked with finding the greatest common divisor (GCD) of two given numbers 'X' and 'Y'. The GCD is defined as the largest integer that divides both of the given...read more

Ans.

Finding the greatest common divisor (GCD) of two given numbers 'X' and 'Y'.

  • Iterate through each test case

  • Use Euclidean algorithm to find GCD

  • Output the GCD for each test case

Add your answer
Q26. Can you write a SQL query that joins two tables A and B on the common attribute ID and selects records (ID_NAME) that have matching ID values in both tables?
Ans.

Yes, I can write a SQL query to join two tables on a common attribute and select matching records.

  • Use INNER JOIN to join tables A and B on the common attribute ID

  • Select the records (ID_NAME) where ID values match in both tables

Add your answer
Q27. Why is Java considered platform independent, while the Java Virtual Machine (JVM) is platform dependent?
Ans.

Java is platform independent because the code is compiled into bytecode that can run on any system with a JVM, which is platform dependent.

  • Java code is compiled into bytecode, which is a platform-independent intermediate code

  • The JVM interprets and executes the bytecode on different platforms, making it platform dependent

  • The JVM acts as a layer of abstraction between the Java code and the underlying operating system

  • Example: A Java program compiled on a Windows machine can run ...read more

Add your answer

Q28. There are five glasses that are kept upside down.At a time you are bound to turn four glasses.Give minimum number of times in which you can turn back all the glasses so that now none among them are upside down

Ans.

Minimum number of times to turn all glasses upside down when 4 can be turned at a time.

  • Turn over any four glasses, leaving one untouched.

  • Repeat the above step until only one glass is left upside down.

  • Finally, turn over the last glass to complete the task.

  • Minimum number of turns required is 3.

Add your answer

Q29. There are 25 horses in which you need to find out the fastest 3 horses. you can conduct a race among at most 5 horses to find out relative speed. At no point, you can find out the actual speed of the horse in a...

read more
Ans.

Minimum 7 races required to find the top 3 fastest horses.

  • Divide the 25 horses into 5 groups of 5 horses each.

  • Conduct a race among the horses in each group to determine the fastest horse in each group.

  • Take the top 2 horses from each group and conduct a race among them to determine the fastest horse overall.

  • The winner of this race is the fastest horse.

  • Now, take the second-place horse from the final race and the second-place horse from each group race.

  • Conduct a race among these...read more

Add your answer
Q30. Can you explain the different types of normalization forms in a DBMS?
Ans.

Normalization forms in a DBMS help reduce data redundancy and improve data integrity.

  • 1NF (First Normal Form) - Each column contains atomic values, and there are no repeating groups.

  • 2NF (Second Normal Form) - Meets 1NF and all non-key attributes are fully functional dependent on the primary key.

  • 3NF (Third Normal Form) - Meets 2NF and there are no transitive dependencies between non-key attributes.

  • BCNF (Boyce-Codd Normal Form) - Every determinant is a candidate key.

  • 4NF (Fourth ...read more

Add your answer

Q31. Code: – Given the value of a starting position and an ending position, you have to reach from start to end in a linear way, and you can move either to position immediate right to current position or two step ri...

read more
Ans.

Print all possible paths from start to end in a linear way, moving either one or two steps right.

  • Use dynamic programming to solve the problem

  • Create a 2D array to store the number of paths to each position

  • Start from the end position and work backwards

  • At each position, calculate the number of paths by summing the number of paths from the next two positions

  • Print all the paths by backtracking from the start position

Add your answer

Q32. There are 25 horses and only 5 horses can be raced at a time and the top 3 are announced in each such race. What is the minimum number of races required to find the top 3 among 25 horses

Ans.

The minimum number of races required to find the top 3 among 25 horses is 7.

  • Divide the 25 horses into 5 groups of 5 horses each.

  • Race the 5 groups, which will give us the top 3 horses from each group.

  • Now we have 15 horses remaining.

  • Race the top 3 horses from each group, which will give us the top 3 horses overall.

  • This requires a total of 7 races.

Add your answer
Q33. Can you explain the concepts of method overloading and method overriding in object-oriented programming?
Ans.

Method overloading is when multiple methods in the same class have the same name but different parameters. Method overriding is when a subclass provides a specific implementation of a method that is already provided by its superclass.

  • Method overloading allows a class to have multiple methods with the same name but different parameters. For example, having multiple constructors in a class with different parameter lists.

  • Method overriding occurs when a subclass provides a specif...read more

Add your answer

Q34. What are abstract classes in Java and what is the difference between an abstract class and an interface

Ans.

Abstract classes in Java are classes that cannot be instantiated and are used as blueprints for other classes.

  • Abstract classes cannot be instantiated, meaning you cannot create objects of an abstract class.

  • Abstract classes can have both abstract and non-abstract methods.

  • Interfaces in Java are similar to abstract classes, but they cannot have any method implementations.

  • A class can implement multiple interfaces, but it can only extend one abstract class.

  • Abstract classes can hav...read more

Add your answer
Q35. What is the difference between a clustered index and a non-clustered index?
Ans.

Clustered index physically reorders the data in the table, while non-clustered index does not.

  • Clustered index determines the physical order of data in the table, while non-clustered index does not.

  • A table can have only one clustered index, but multiple non-clustered indexes.

  • Clustered index is faster for retrieval of data, as it directly points to the actual data rows.

  • Non-clustered index is faster for retrieval of specific data, as it points to a separate list of pointers to t...read more

Add your answer

Q36. Write a code for inserting two numbers in a text file given n2>n1 and the next entry should not be overlapping like if first was 4,6 next can't be 5,7.the second n1 has to be greater than first n2

Ans.

The code inserts two numbers in a text file, ensuring that the second number is greater than the first and there is no overlap between entries.

  • Read the existing entries from the text file

  • Check if the new numbers satisfy the conditions

  • If conditions are met, insert the new numbers into the file

  • Otherwise, display an error message

Add your answer
Q37. What is the difference between an Abstract Class and an Interface in Java?
Ans.

Abstract class can have both abstract and non-abstract methods, while interface can only have abstract methods.

  • Abstract class can have constructors, member variables, and methods, while interface cannot have any of these.

  • A class can extend only one abstract class but can implement multiple interfaces.

  • Abstract classes are used to provide a common base for subclasses, while interfaces are used to define a contract for classes to implement.

  • Example: Abstract class - Animal with a...read more

Add your answer

Q38. What is overloading and what is overriding. Explain each with example

Ans.

Overloading is when multiple methods have the same name but different parameters. Overriding is when a subclass provides a different implementation of a method inherited from its superclass.

  • Overloading allows a class to have multiple methods with the same name but different parameters.

  • Overriding occurs when a subclass provides a different implementation of a method inherited from its superclass.

  • Overloading is resolved at compile-time based on the method signature.

  • Overriding i...read more

Add your answer
Q39. What is the major difference between 32-bit and 64-bit processors?
Ans.

The major difference between 32-bit and 64-bit processors is the amount of memory they can access and process.

  • 32-bit processors can access up to 4GB of RAM, while 64-bit processors can access much more, typically 16 exabytes (16 billion GB) of RAM.

  • 64-bit processors can handle larger chunks of data at once, leading to improved performance in tasks that require intensive calculations or large datasets.

  • Software designed for 64-bit processors may not be compatible with 32-bit pro...read more

Add your answer
Q40. What are the differences between a mutex and a semaphore?
Ans.

Mutex is used for exclusive access to a resource, while semaphore is used for controlling access to a resource by multiple threads.

  • Mutex is binary and allows only one thread to access the resource at a time.

  • Semaphore can have a count greater than one, allowing multiple threads to access the resource simultaneously.

  • Mutex is used for protecting critical sections of code, while semaphore is used for synchronization between threads.

  • Example: Mutex is like a key to a room that only...read more

Add your answer
Q41. Can you explain the concepts of multitasking and multiprogramming?
Ans.

Multitasking involves executing multiple tasks simultaneously, while multiprogramming involves running multiple programs on a single processor.

  • Multitasking allows multiple tasks to run concurrently, switching between them quickly.

  • Multiprogramming involves loading multiple programs into memory and executing them concurrently.

  • Examples of multitasking include running multiple applications on a computer or a smartphone.

  • Examples of multiprogramming include running multiple instanc...read more

Add your answer

Q42. How is undo operation (ctrl + z) implemented internally?

Ans.

Undo operation (ctrl + z) is implemented by maintaining a stack of previous states.

  • When a change is made, the current state is pushed onto the stack

  • When undo is called, the top state is popped and applied

  • Redo is implemented by maintaining a stack of undone states

  • Some applications may also implement a limit on the number of undo/redo steps

  • Undo/redo can be implemented at different levels (e.g. character, word, paragraph)

Add your answer
Q43. What is the main difference between UNION and UNION ALL?
Ans.

UNION removes duplicates while UNION ALL does not

  • UNION combines result sets and removes duplicates

  • UNION ALL combines result sets without removing duplicates

  • UNION is slower than UNION ALL as it involves removing duplicates

  • Use UNION when you want to remove duplicates, use UNION ALL when duplicates are acceptable

Add your answer

Q44. How do you measure 4 liters with a 5 liters and 3 liters container

Ans.

You can measure 4 liters by following these steps:

  • Fill the 5 liters container completely

  • Pour the 5 liters into the 3 liters container, leaving 2 liters in the 5 liters container

  • Empty the 3 liters container

  • Pour the remaining 2 liters from the 5 liters container into the 3 liters container

  • Fill the 5 liters container again

  • Pour 1 liter from the 5 liters container into the 3 liters container, which now has 3 liters

  • The 5 liters container now has 4 liters

Add your answer

Q45. to explain algorithm of the project that I’m going to do in the upcoming semester and asked me code it

Ans.

The algorithm for the upcoming semester project involves developing an application.

  • Identify the requirements and objectives of the project

  • Design the application architecture and user interface

  • Implement the necessary algorithms and data structures

  • Test and debug the application

  • Optimize the performance and efficiency of the code

  • Document the project for future reference

Add your answer

Q46. Write code to find the middle element of a linked list

Ans.

Code to find the middle element of a linked list

  • 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 element

  • If the linked list has even number of elements, return the second middle element

Add your answer

Q47. Write a code to count the number of times '1' occurs from 1 to 999999

Ans.

Code to count the number of times '1' occurs from 1 to 999999

  • Loop through all numbers from 1 to 999999

  • Convert each number to a string and count the number of '1's in it

  • Add the count to a running total

  • Return the total count

Add your answer

Q48. Given a matrix.Write a code to print the transpose of the matrix

Ans.

The code prints the transpose of a given matrix.

  • Iterate through each row and column of the matrix.

  • Swap the elements at the current row and column with the elements at the current column and row.

  • Print the transposed matrix.

Add your answer
Q49. What do you mean by virtual functions in C++?
Ans.

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.

  • Virtual functions enable polymorphism, allowing objects of different derived classes to be treated as objects of the base class.

  • Example: class Shape { virtual void draw() { ... } }; class Circle : public Shape { void draw(...read more

Add your answer

Q50. Find the common ancestor of two given nodes in a tree

Ans.

Find the common ancestor of two given nodes in a tree

  • Traverse the tree from the root node

  • Check if both nodes are on the same side of the current node

  • If not, return the current node as the common ancestor

  • If yes, continue traversing down that side of the tree

Add your answer
Q51. Explain the difference between the DELETE and TRUNCATE commands in a DBMS.
Ans.

DELETE removes specific rows from a table, while TRUNCATE removes all rows and resets auto-increment values.

  • DELETE is a DML command, while TRUNCATE is a DDL command.

  • DELETE can be rolled back, while TRUNCATE cannot be rolled back.

  • DELETE triggers ON DELETE triggers, while TRUNCATE does not trigger any triggers.

  • DELETE is slower as it logs individual row deletions, while TRUNCATE is faster as it logs the deallocation of the data pages.

  • Example: DELETE FROM table_name WHERE conditi...read more

Add your answer

Q52. What is time complexity of 8 queens algorithm

Ans.

The time complexity of 8 queens algorithm is O(n!).

  • The algorithm checks all possible permutations of the queens on the board.

  • The number of permutations is n! where n is the number of queens.

  • For 8 queens, there are 8! = 40,320 possible permutations.

  • The algorithm has to check each permutation to find a valid solution.

  • Therefore, the time complexity is O(n!).

Add your answer

Q53. Puzzle: Gi1ven 4 coins, arrange then to make maximum numbers of triangle of the figure

Ans.

Arrange 4 coins to make maximum number of triangles

  • Place 3 coins in a triangle formation and the fourth coin in the center to form 4 triangles

  • Place 2 coins on top of each other and the other 2 coins on either side to form 2 triangles

  • Place 2 coins in a line and the other 2 coins on either side to form 2 triangles

Add your answer

Q54. What is your favorite program and why is it so

Ans.

My favorite program is Visual Studio Code because of its user-friendly interface and extensive plugin library.

  • User-friendly interface with customizable settings

  • Extensive plugin library for various programming languages and tools

  • Integrated terminal and debugging features

  • Supports Git version control

  • Frequent updates and improvements

  • Free and open-source

  • Examples: Python, JavaScript, HTML/CSS, Git

Add your answer

Q55. Puzzle: Given 10 coins, arrange them such that we get 4 different rows each containing 4 coins

Ans.

Arrange 10 coins in 4 rows of 4 coins each.

  • Place 4 coins in a row and keep the remaining 6 aside.

  • Place 3 coins from the remaining 6 in the next row and keep the remaining 3 aside.

  • Place 2 coins from the remaining 3 in the third row and keep the remaining 1 aside.

  • Place the last coin in the fourth row along with the remaining 1 coin from step 3.

  • The final arrangement will have 4 rows with 4 coins each.

Add your answer

Q56. Programs like count the frequency of every alphabet in a string

Ans.

Count the frequency of each alphabet in a string.

  • Iterate through the string and count the occurrence of each alphabet using a dictionary or array.

  • Convert the string to lowercase or uppercase to avoid case sensitivity.

  • Exclude non-alphabetic characters using regular expressions.

  • Consider using built-in functions or libraries for efficiency.

  • Handle edge cases such as empty strings or strings with no alphabetic characters.

Add your answer

Q57. Find the number of palindromes in a big string

Ans.

Count the number of palindromes in a given string.

  • A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward.

  • Iterate through the string and check if each substring is a palindrome.

  • Use two pointers, one at the beginning and one at the end of the substring, and move them towards each other until they meet in the middle.

  • If the substring is a palindrome, increment the count.

  • Consider both even and odd length palindromes.

Add your answer

Q58. Find the fifth largest element in a linked list

Ans.

Find the fifth largest element in a linked list

  • Traverse the linked list and store the elements in an array

  • Sort the array in descending order

  • Return the fifth element in the sorted array

Add your answer

Q59. Explain multitasking and multiprogramming

Ans.

Multitasking is the ability of an operating system to run multiple tasks concurrently while multiprogramming is the ability to run multiple programs concurrently.

  • Multitasking allows multiple tasks to run concurrently on a single processor system.

  • Multiprogramming allows multiple programs to run concurrently on a single processor system.

  • Multitasking is achieved through time-sharing, where the processor switches between tasks at a very high speed.

  • Multiprogramming is achieved thr...read more

Add your answer

Q60. Find the maximum salary in emp table

Ans.

To find the maximum salary in emp table, use the MAX function on the salary column.

  • Use the MAX function in SQL to find the highest value in a column

  • Specify the column name after the MAX function, in this case 'salary'

  • Example: SELECT MAX(salary) FROM emp

  • This will return the highest salary value in the emp table

Add your answer
Q61. What are constraints in SQL?
Ans.

Constraints in SQL are rules that are enforced on columns or tables to ensure data integrity and consistency.

  • Constraints ensure data accuracy and reliability.

  • Common constraints include NOT NULL, UNIQUE, PRIMARY KEY, FOREIGN KEY, and CHECK.

  • NOT NULL constraint ensures a column cannot have a NULL value.

  • UNIQUE constraint ensures that all values in a column are unique.

  • PRIMARY KEY constraint uniquely identifies each record in a table.

  • FOREIGN KEY constraint establishes a relationshi...read more

Add your answer

Q62. What are ER diagrams for?

Ans.

ER diagrams are used to visualize and design relational databases.

  • ER diagrams show the relationships between entities in a database

  • They help in identifying the attributes of each entity

  • They aid in designing the structure of a database

  • ER diagrams are commonly used in software development

Add your answer

Q63. Design circular doubly linked list with all operations.

Ans.

Circular doubly linked list is a data structure where each node has a reference to both the next and previous nodes, forming a circular loop.

  • Create a Node class with data, next, and prev pointers

  • Implement operations like insert, delete, search, and display

  • Ensure the last node's next pointer points to the first node and the first node's prev pointer points to the last node

Add your answer

Q64. Different types of searching and sorting algo discussion.

Ans.

Searching and sorting algorithms are essential in programming for efficiently organizing and retrieving data.

  • Searching algorithms: linear search, binary search, depth-first search, breadth-first search

  • Sorting algorithms: bubble sort, selection sort, insertion sort, merge sort, quick sort

  • Examples: Searching for a specific item in a list, sorting a list of numbers in ascending order

Add your answer

Q65. Write code for Towers of Hanoi problem

Ans.

Towers of Hanoi is a classic problem of moving disks from one peg to another with specific rules.

  • The problem involves three pegs and a number of disks of different sizes.

  • The goal is to move all the disks from the first peg to the third peg, while following the rules.

  • The rules are: only one disk can be moved at a time, a larger disk cannot be placed on top of a smaller disk, and all disks must be moved to the third peg.

  • The solution can be implemented recursively.

  • Example code: ...read more

Add your answer

Q66. Explain three normalizations with example

Ans.

Explanation of three normalizations with examples

  • First Normal Form (1NF): Eliminate duplicate data and create separate tables for related data

  • Example: A table with customer information and their orders should be split into two tables

  • Second Normal Form (2NF): Ensure non-key attributes are dependent on the primary key

  • Example: A table with customer information and their orders should have separate tables for customer and order details

  • Third Normal Form (3NF): Eliminate transitive...read more

Add your answer

Q67. Find the duplicates in an array

Ans.

Find duplicates in an array

  • Iterate through the array and compare each element with the rest of the elements

  • Use a hash table to keep track of the frequency of each element

  • Sort the array and compare adjacent elements

  • Use a set to keep track of unique elements and add duplicates to another set

Add your answer

Q68. Difference between semaphore and mutex

Ans.

Semaphore allows multiple threads to access shared resources at the same time, while mutex allows only one thread at a time.

  • Semaphore is used to control access to a resource with limited capacity, like a printer or database connection pool.

  • Mutex is used to protect a shared resource from simultaneous access, like a critical section of code.

  • Semaphore can have a count greater than 1, allowing multiple threads to access the resource simultaneously.

  • Mutex has a binary state, either...read more

Add your answer

Q69. Implement queue using linked lists

Ans.

Implementing queue using linked lists

  • Create a Node class with data and next pointer

  • Create a Queue class with head and tail pointers

  • Enqueue by adding a new node at the tail and dequeue by removing the head node

  • Check for empty queue by checking if head is null

Add your answer

Q70. minimum area of square that contains all the points

Ans.

The minimum area of a square that contains all given points is the square of the maximum distance between any two points.

  • Calculate the distance between all pairs of points

  • Find the maximum distance

  • Square the maximum distance to get the minimum area of the square

Add your answer

Q71. design hashmap from scratch

Ans.

Designing a hashmap from scratch

  • A hashmap is a data structure that allows for efficient key-value pair storage and retrieval

  • It typically uses an array and a hashing function to map keys to array indices

  • Collision handling techniques like chaining or open addressing may be used

  • Operations like insert, delete, and search can be implemented using the hashmap

  • Example: Designing a hashmap to store student records with their roll numbers as keys

Add your answer

Q72. Largest element in window size K

Ans.

Find the largest element in a window of size K in an array.

  • Iterate through the array and maintain a deque to store the indices of elements in decreasing order.

  • Remove indices from the front of the deque that are outside the current window.

  • The front of the deque will always have the index of the largest element in the current window.

Add your answer

Q73. Merge two sorted linked lists

Ans.

Merge two sorted linked lists

  • Create a new linked list to store the merged list

  • Compare the first nodes of both lists and add the smaller one to the new list

  • Move the pointer of the added node to the next node

  • Repeat until one of the lists is empty, then add the remaining nodes to the new list

Add your answer

Q74. Explain 8 queens algorithm

Ans.

8 Queens Algorithm is a backtracking algorithm to place 8 queens on a chessboard without attacking each other.

  • The algorithm places one queen in each column, starting from the leftmost column.

  • If a queen can be placed in a row without attacking another queen, it is placed there.

  • If no such row exists, the algorithm backtracks to the previous column and tries a different row.

  • The algorithm continues until all 8 queens are placed on the board without attacking each other.

  • The algori...read more

Add your answer

Q75. Explain interfaces in Java

Ans.

Interfaces in Java define a contract for classes to implement certain methods.

  • Interfaces are like a blueprint for classes to follow

  • They can contain method signatures but no implementation

  • Classes can implement multiple interfaces

  • Interfaces can extend other interfaces

  • Example: Comparable interface for sorting objects

Add your answer

Q76. Maximum length of subarray of given sum

Ans.

Find the maximum length of a subarray with a given sum in an array.

  • Use a hashmap to store the running sum and its corresponding index.

  • Iterate through the array and update the hashmap with the running sum.

  • Check if the difference between the current sum and the target sum exists in the hashmap to find the subarray length.

Add your answer

Q77. Traversing singly linked list

Ans.

Traversing a singly linked list involves iterating through each node starting from the head node.

  • Start at the head node

  • Iterate through each node by following the 'next' pointer

  • Stop when reaching the end of the list (next pointer is null)

Add your answer

Q78. Explain heap sort

Ans.

Heap sort is a comparison-based sorting algorithm that uses a binary heap data structure.

  • It divides the input into a sorted and an unsorted region.

  • It repeatedly extracts the largest element from the unsorted region and inserts it into the sorted region.

  • It has a worst-case and average-case time complexity of O(n log n).

Add your answer

Q79. Reverse a string

Ans.

Reverse a string

  • Use a loop to iterate through the string and append each character to a new string in reverse order

  • Alternatively, use the built-in reverse() method for strings in some programming languages

Add your answer

Q80. sum 2 linkedlists in efficient way

Ans.

Use iterative approach to traverse both linked lists and sum corresponding nodes while keeping track of carry.

  • Iterate through both linked lists simultaneously

  • Sum corresponding nodes and carry from previous sum

  • Create a new linked list to store the sum

Add your answer

Q81. Hotel booking system design

Ans.

Design a hotel booking system.

  • Create a database to store hotel information, room availability, and bookings.

  • Develop a user interface for customers to search and book hotels.

  • Implement a payment gateway for secure transactions.

  • Include features like room selection, date selection, and guest information.

  • Consider implementing a rating and review system for hotels.

  • Ensure the system can handle concurrent bookings and prevent double bookings.

Add your answer

Q82. Sql query using joins

Ans.

SQL query using joins

  • Use JOIN keyword to combine rows from two or more tables based on a related column between them

  • Types of joins include INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN

  • Example: SELECT * FROM table1 INNER JOIN table2 ON table1.column = table2.column

Add your answer

Q83. Merge two sorted arrays

Ans.

Merge two sorted arrays into a single sorted array

  • Create a new array to store the merged result

  • Use two pointers to iterate through both arrays and compare elements

  • Add the smaller element to the new array and move the pointer for that array

Add your answer

Q84. Shallow copy vs Deep copy

Ans.

Shallow copy only copies the references of objects, while deep copy creates new copies of objects.

  • Shallow copy creates a new object but does not create copies of nested objects.

  • Deep copy creates new copies of all nested objects.

  • Shallow copy is faster and more memory efficient, but changes to nested objects affect both copies.

  • Deep copy is slower and uses more memory, but changes to nested objects do not affect the original object.

Add your answer

Q85. Design Tic Tac Toe

Ans.

Design a Tic Tac Toe game

  • Create a 3x3 grid to represent the game board

  • Allow two players to take turns marking X and O on the grid

  • Check for win conditions after each move to determine the winner

  • Handle tie game if all spaces are filled without a winner

Add your answer

Q86. Find area using co ordinates

Ans.

Calculate the area of a shape using coordinates

  • Determine the type of shape (e.g. rectangle, triangle, circle)

  • Use the appropriate formula for the shape to calculate the area

  • Input the coordinates into the formula to get the area

Add your answer

Q87. Intersection of linked list

Ans.

Intersection of linked list is finding the common node where two linked lists merge.

  • Traverse both linked lists to find their lengths

  • Align the longer list's pointer to match the length of the shorter list

  • Iterate through both lists simultaneously to find the intersection node

Add your answer

More about working at Oracle

#22 Best Mega Company - 2022
#3 Best Internet/Product Company - 2022
Contribute & help others!
Write a review
Share interview
Contribute salary
Add office photos

Interview Process at Sunny Industries

based on 27 interviews
5 Interview rounds
Technical Round - 1
Coding Test Round
Technical Round - 2
HR Round
Personal Interview1 Round
View more
Interview Tips & Stories
Ace your next interview with expert advice and inspiring stories

Top Application Developer Interview Questions from Similar Companies

3.8
 • 223 Interview Questions
4.0
 • 44 Interview Questions
3.7
 • 28 Interview Questions
3.8
 • 25 Interview Questions
3.9
 • 15 Interview Questions
View all
Share an Interview
Stay ahead in your career. Get AmbitionBox app
qr-code
Helping over 1 Crore job seekers every month in choosing their right fit company
70 Lakh+

Reviews

5 Lakh+

Interviews

4 Crore+

Salaries

1 Cr+

Users/Month

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2024 Info Edge (India) Ltd.

Follow us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter