Learnitweb

Author: Editorial Team

  • Longest Common Subsequence

    Problem StatementYou are given two strings text1 and text2. Your task is to return the length of their longest common subsequence.A subsequence of a string is a new string that is formed by deleting some (or none) of the characters without changing the order of the remaining characters. ExampleInput:text1 = “abcde”, text2 = “ace”Output:3Explanation: The…

  • Jump Game

    Problem StatementYou are given an integer array nums, where each element represents the maximum number of steps you can jump forward from that position.Your task is to determine if you can reach the last index starting from the first index. ExampleInput: nums = [2, 3, 1, 1, 4]Output: trueExplanation: Start at index 0, jump 1…

  • LRU Cache

    Problem Statement Design a Least Recently Used (LRU) Cache data structure. You need to implement a class LRUCache with the following operations: Example Output: [1, -1, -1, 3, 4] Understanding the Problem An LRU Cache should do two things efficiently: If the cache is full, we must remove the least recently used key before inserting…

  • Bitwise AND of Numbers Range

    Problem Statement You are given two integers left and right representing a range [left, right] (inclusive).You need to find the bitwise AND of all numbers in this range. Example Explanation: Understanding the Problem The bitwise AND (&) operation compares each bit of two numbers: If we take the AND of a continuous range of numbers,…

  • Subarray Sum Equals K

    Problem Statement You are given an integer array nums and an integer k.Your task is to find the total number of continuous subarrays whose sum equals k. Example There are two subarrays that sum up to 2: [1,1] (from index 0 to 1) and [1,1] (from index 1 to 2). 1. Understanding the Problem A…

  • JEP 456: Unnamed Variables & Patterns

    What is JEP 456? JEP 456 is a feature of Java 22 that finalizes the capability to use “unnamed variables” and “unnamed patterns”. In short, when you need a variable binder (in a local variable declaration, exception parameter, lambda parameter, loop header, or pattern matching) but you are never going to use that variable, you…

  • Implementing Cache with Redisson in a Spring Boot Reactive Application

    In this tutorial, we will extend our existing Spring Boot application to integrate caching using Redisson. The goal is to create a clean architecture that separates caching logic from the service layer using a template method design pattern, so we can reuse caching logic across different entities. We will also demonstrate performance testing using Gatling,…

  • Building a Reactive Spring Boot Application with PostgreSQL and Performance Testing

    In this tutorial, we will create a simple Spring Boot application to manage products, store data in PostgreSQL using R2DBC, and verify performance using Gatling. This approach is suitable for real-world applications where you want reactive programming and performance insights. 1. Project Setup 2. Database Setup: PostgreSQL with Docker We will run PostgreSQL in a…

  • Advanced Spring Boot Caching: @Cacheable, @CachePut, @CacheEvict, and Scheduled Updates

    Caching is essential for improving application performance and reducing load on external resources. Spring Boot provides several annotations to manage caching in a flexible manner. 1. Understanding the Core Annotations 1.1 @Cacheable Key points: 1.2 @CacheEvict Notes: 1.3 @CachePut Use case: 2. Practical Example: Weather Service with Scheduled Cache Updates 2.1 Use Case 2.2 Service…

  • Advanced Redis Caching in Spring Boot: Cache Eviction and Scheduled Cache Clearing

    In previous lectures, we implemented Redis caching for a Fibonacci service using the @Cacheable annotation. While caching improves performance, it introduces the need for cache management strategies, including eviction and scheduled clearing. This tutorial explains these concepts in detail. 1. Why Cache Eviction is Important When you use @Cacheable: Scenarios where eviction is necessary: 2.…