0% found this document useful (0 votes)
43 views

Technical Program

yess very good

Uploaded by

Sooryamol S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

Technical Program

yess very good

Uploaded by

Sooryamol S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

For the first technical round of interviews at HashedIn, you can expect to face

questions that assess your problem-solving abilities, understanding of data


structures and algorithms, and your proficiency in Java. Here are some key areas
and sample questions to help you prepare:

### Key Areas to Focus On

1. **Data Structures**: Arrays, Linked Lists, Stacks, Queues, Trees, Graphs, Hash
Tables, and Heaps.
2. **Algorithms**: Sorting, Searching, Dynamic Programming, Greedy Algorithms,
Backtracking, and Graph Algorithms.
3. **Programming Concepts**: Object-Oriented Programming (OOP), Design Patterns,
Exception Handling, and Multithreading.
4. **Java-Specific Questions**: Understanding of core Java concepts such as
Collections Framework, Java Memory Model, Java Concurrency, and Java 8 features
(like Streams and Lambdas).

### Sample Questions and Solutions

#### Data Structures and Algorithms

1. **Find the Middle of a Linked List**:


```java
class ListNode {
int val;
ListNode next;
ListNode(int x) { val = x; }
}

public class LinkedListMiddle {


public ListNode findMiddle(ListNode head) {
if (head == null) return null;
ListNode slow = head;
ListNode fast = head;
while (fast != null && fast.next != null) {
slow = slow.next;
fast = fast.next.next;
}
return slow;
}
}
```

2. **Check for Balanced Parentheses using Stack**:


```java
import java.util.Stack;

public class BalancedParentheses {


public boolean isValid(String s) {
Stack<Character> stack = new Stack<>();
for (char c : s.toCharArray()) {
if (c == '(' || c == '{' || c == '[') {
stack.push(c);
} else {
if (stack.isEmpty()) return false;
char top = stack.pop();
if ((c == ')' && top != '(') || (c == '}' && top != '{') || (c
== ']' && top != '[')) {
return false;
}
}
}
return stack.isEmpty();
}
}
```

3. **Binary Search**:
```java
public class BinarySearch {
public int binarySearch(int[] nums, int target) {
int left = 0, right = nums.length - 1;
while (left <= right) {
int mid = left + (right - left) / 2;
if (nums[mid] == target) return mid;
if (nums[mid] < target) left = mid + 1;
else right = mid - 1;
}
return -1;
}
}
```

4. **Merge Two Sorted Arrays**:


```java
public class MergeSortedArrays {
public int[] merge(int[] nums1, int m, int[] nums2, int n) {
int i = m - 1, j = n - 1, k = m + n - 1;
while (i >= 0 && j >= 0) {
if (nums1[i] > nums2[j]) {
nums1[k--] = nums1[i--];
} else {
nums1[k--] = nums2[j--];
}
}
while (j >= 0) {
nums1[k--] = nums2[j--];
}
return nums1;
}
}
```

5. **Find the Longest Palindromic Substring**:


```java
public class LongestPalindromicSubstring {
public String longestPalindrome(String s) {
if (s == null || s.length() < 1) return "";
int start = 0, end = 0;
for (int i = 0; i < s.length(); i++) {
int len1 = expandAroundCenter(s, i, i);
int len2 = expandAroundCenter(s, i, i + 1);
int len = Math.max(len1, len2);
if (len > end - start) {
start = i - (len - 1) / 2;
end = i + len / 2;
}
}
return s.substring(start, end + 1);
}

private int expandAroundCenter(String s, int left, int right) {


while (left >= 0 && right < s.length() && s.charAt(left) ==
s.charAt(right)) {
left--;
right++;
}
return right - left - 1;
}
}
```

#### Object-Oriented Programming (OOP)

1. **Design a Simple Library Management System**:


```java
import java.util.*;

class Book {
private String title;
private String author;
private String ISBN;
private boolean isAvailable;

public Book(String title, String author, String ISBN) {


this.title = title;
this.author = author;
this.ISBN = ISBN;
this.isAvailable = true;
}

// Getters and Setters

public boolean isAvailable() {


return isAvailable;
}

public void setAvailable(boolean available) {


isAvailable = available;
}

// Other methods
}

class Library {
private Map<String, Book> books;

public Library() {
this.books = new HashMap<>();
}

public void addBook(Book book) {


books.put(book.getISBN(), book);
}

public void removeBook(String ISBN) {


books.remove(ISBN);
}

public Book findBookByISBN(String ISBN) {


return books.get(ISBN);
}

public void checkoutBook(String ISBN) {


Book book = books.get(ISBN);
if (book != null && book.isAvailable()) {
book.setAvailable(false);
System.out.println("Book checked out successfully.");
} else {
System.out.println("Book is not available.");
}
}

public void returnBook(String ISBN) {


Book book = books.get(ISBN);
if (book != null && !book.isAvailable()) {
book.setAvailable(true);
System.out.println("Book returned successfully.");
} else {
System.out.println("Book was not checked out.");
}
}

// Other methods
}

public class LibraryManagementSystem {


public static void main(String[] args) {
Library library = new Library();
Book book1 = new Book("The Great Gatsby", "F. Scott Fitzgerald",
"12345");
Book book2 = new Book("1984", "George Orwell", "67890");

library.addBook(book1);
library.addBook(book2);

library.checkoutBook("12345");
library.returnBook("12345");
library.checkoutBook("67890");
}
}
```

#### Java-Specific Questions

1. **Java Collections Framework**:


- **Example: Using HashMap**:
```java
import java.util.HashMap;
import java.util.Map;

public class HashMapExample {


public static void main(String[] args) {
Map<String, Integer> map = new HashMap<>();
map.put("Alice", 30);
map.put("Bob", 25);
map.put("Charlie", 35);

for (Map.Entry<String, Integer> entry : map.entrySet()) {


System.out.println(entry.getKey() + ": " + entry.getValue());
}
}
}
```

2. **Java 8 Features**:
- **Example: Using Streams and Lambdas**:
```java
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class StreamExample {


public static void main(String[] args) {
List<String> names = Arrays.asList("Alice", "Bob", "Charlie", "David",
"Edward");

// Filtering names that start with 'A'


List<String> filteredNames = names.stream()
.filter(name ->
name.startsWith("A"))
.collect(Collectors.toList());

// Printing filtered names


filteredNames.forEach(System.out::println);

// Using map to convert names to uppercase


List<String> upperCaseNames = names.stream()
.map(String::toUpperCase)
.collect(Collectors.toList());

// Printing uppercase names


upperCaseNames.forEach(System.out::println);
}
}
```

### Preparation Tips


- **Practice Coding**: Solve problems on platforms like LeetCode, HackerRank, and
CodeSignal focusing on Java.
- **Understand Core Concepts**: Make sure you understand the core concepts of data
structures, algorithms, and OOP principles.
- **Revise Java Basics**: Review Java basics, especially Collections Framework,
Exception Handling, and Multithreading.
- **Mock Interviews**: Practice mock interviews with a friend or use platforms like
Pramp or Interviewing.io to simulate the interview environment.

By focusing on these areas and practicing the sample questions, you'll be well-
prepared for the first technical round at HashedIn.

You might also like