Posted on: February 1, 2025 Posted by: rahulgite Comments: 0

SQL Queries for Interview

Problem 1: Combine Two Tables Explanation: Write a SQL query to combine two tables, Person and Address, by PersonId, ensuring that if an address is missing, it still appears in the output. SQL Approach: SQL Query: Example: Input: Output: Edge Cases Considered: Problem 2: Second Highest Salary Explanation: Write a SQL query to get the second highest salary from the Employee table. If there is no second highest salary, return…

Posted on: February 1, 2025 Posted by: rahulgite Comments: 0

Dynamic Programming

Problem 1: Climbing Stairs Explanation: You are climbing a staircase. It takes n steps to reach the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Approach: Time & Space Complexity: Java Implementation: Example: Input: Output: Edge Cases Considered: Problem 2: House Robber Explanation: Given an integer array nums representing the amount of money in houses, return…

Posted on: February 1, 2025 Posted by: rahulgite Comments: 0

Tree & Graph Problems

Problem 1: Maximum Depth of Binary Tree Explanation: Given a binary tree, return its maximum depth. Approach: Time & Space Complexity: Java Implementation: Example: Input: Output: Edge Cases Considered: Problem 2: Validate Binary Search Tree Explanation: Given a binary tree, determine if it is a valid Binary Search Tree (BST). Approach: Time & Space Complexity: Java Implementation: Example: Input: Output: Edge Cases Considered: Problem 3: Count Complete Tree Nodes Explanation:…

Posted on: February 1, 2025 Posted by: rahulgite Comments: 0

String Problems

Problem 1: Longest Common Prefix Explanation: Given an array of strings, find the longest common prefix among them. If no common prefix exists, return an empty string. Approach: Time & Space Complexity: Java Implementation: Example: Input: Output: Edge Cases Considered: Problem 2: Valid Anagram Explanation: Given two strings s and t, return true if t is an anagram of s, and false otherwise. Approach: Time & Space Complexity: Java Implementation:…

Posted on: February 1, 2025 Posted by: rahulgite Comments: 0

Linked List problems

Problem 1: Linked List Cycle Explanation: Given a linked list, determine if it has a cycle in it. Approach: Time & Space Complexity: Java Implementation: Example: Input: Output: Edge Cases Considered: Problem 2: Intersection of Two Linked Lists Explanation: Given the heads of two singly linked lists, return the node where the two lists intersect, or null if they do not intersect. Approach: Time & Space Complexity: Java Implementation: Example:…

Posted on: February 1, 2025 Posted by: rahulgite Comments: 0

Array Problems

Problem 1: Remove Duplicates from Sorted Array Explanation: Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Approach: Time & Space Complexity: Java Implementation: Example: Input: Output: Edge Cases Considered: Problem 2: Maximum Subarray Explanation: Given an integer array nums, find the contiguous subarray (containing at least…

Posted on: February 1, 2025 Posted by: rahulgite Comments: 0

Searching Problems

Problem 1: Search Insert Position Explanation: Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be inserted in order. Approach: Time & Space Complexity: Java Implementation: Example: Input: Output: Edge Cases Considered: Problem 2: Binary Search Explanation: Given a sorted array of integers and a target value, return the index of the…

Posted on: February 1, 2025 Posted by: rahulgite Comments: 0

Sorting Problems

Problem 1: Sort Array By Parity Explanation: Given an integer array nums, we need to rearrange the elements so that all even numbers appear before all odd numbers. The order among even or odd numbers does not matter. Approach: Time & Space Complexity: Java Implementation: Example: Input: Output: (or any other valid order where even numbers come first) Edge Cases Considered: Problem 2: Squares of a Sorted Array Explanation: Given…

Posted on: February 1, 2025 Posted by: rahulgite Comments: 0

DSA

1️⃣ Sorting & Searching Problems 2️⃣ Array & Matrix Problems 3️⃣ Linked List Problems 4️⃣ String Problems 5️⃣ Tree & Graph Problems 6️⃣ Dynamic Programming Problems 7️⃣ Stack & Queue Problems 8️⃣ Miscellaneous Problems

Posted on: January 24, 2025 Posted by: rahulgite Comments: 0

Kafka Q&A

Core Concepts What is Apache Kafka, and how does it work? Apache Kafka is a distributed event streaming platform used for building real-time data pipelines and streaming applications. It is designed to handle high-throughput, low-latency data processing. Kafka allows systems to publish, store, and consume streams of records in a fault-tolerant manner. At its core, Kafka consists of brokers that manage the data, producers that send data to Kafka, and…