Description:
You are given an array of integers. A peak element is an element that is strictly greater than its immediate neighbors. For boundary elements (the first and last elements), only one neighbor needs to be considered. Your task is to write a function that finds and returns any one peak element from the array.
Constraints:
The array contains at least one element.
Example:
Input: [1, 3, 20, 4, 1, 0]
Output: 20
Explanation: 20 is greater than both 3 and 4, so it is considered a peak element.
Identify and explain the differences between many-to-one and many-to-many relationships in relational databases, and describe how they are represented in database schema design.
Please provide practical examples and explain how many-to-one and many-to-many relationships are typically implemented in relational databases using foreign keys and junction tables.
Explain how the sequence in which code is written (writing order) may differ from the sequence in which it is actually executed (execution order). Highlight how control flow constructs, function calls, and asynchronous operations can cause deviations between the two.
Explain how to design an entity class in a Spring Boot application. Describe the key components involved, including commonly used JPA annotations (such as @Entity, @Table, @Id, @GeneratedValue, @Column), how the entity maps to a database table, and best practices to follow when defining entity classes (e.g., using proper data types, meaningful class and field names, avoiding business logic inside entities, and implementing Serializable when needed).
Explain what a functional interface is in Java, including its characteristics (an interface with exactly one abstract method). Describe how lambda expressions can be used with functional interfaces to provide a clear and concise way of implementing the abstract method, thereby reducing boilerplate code compared to traditional anonymous classes.
Describe the common HTTP methods used in RESTful APIs (GET, POST, PUT, DELETE, PATCH) and their corresponding Spring Boot annotations for mapping requests (@GetMapping, @PostMapping, @PutMapping, @DeleteMapping, @PatchMapping). Additionally, explain how data can be extracted from the URL in Spring Boot using path variables (via @PathVariable) and query parameters (via @RequestParam).
Discuss whether it is possible to run a program without a main method, and if so, explain the scenarios where this can occur. Include examples such as the use of static initialization blocks in older versions of Java, execution within frameworks (e.g., JUnit tests, Spring Boot applications) where the framework provides the entry point, and environments that interpret code differently (such as scripting languages).
Explain how a HashMap works internally, including how keys are hashed to determine the index in an array (bucket) and how entries are stored as key-value pairs. Describe what collisions are—situations where multiple keys hash to the same index—and why they occur. Additionally, discuss the common collision resolution techniques such as chaining (linked lists or balanced trees in modern Java) and open addressing (probing strategies), along with their advantages and trade-offs.
Explain the concept of polymorphism in object-oriented programming, where the same interface or method can represent different underlying forms (data types or implementations). Describe the two main types of polymorphism: compile-time (method overloading) and runtime (method overriding), highlighting that runtime polymorphism commonly arises from inheritance. Provide relevant examples to illustrate how polymorphism enhances code flexibility, reusability, and maintainability.

Here's your problem of the day
Solving this problem will increase your chance to get selected in this company
What is recursion?