CDChetan Dattainchetan77.hashnode.dev·1d ago · 3 min readJava Interview Cheat Sheet (Java 17+)Goal: One consistent, modern syntax reference for Java, DSA & backend interviews. 1. Comparator Integer.compare(a,b); // ⭐ Ascending (avoid a-b overflow) Integer.compare(b,a); // ⭐ Descending a.00
CDChetan Dattainchetan77.hashnode.dev·Jul 11 · 9 min readShortest Path in a Grid with Obstacles EliminationProblem You are given an m x n integer matrix grid where each cell is either 0 (empty) or 1 (obstacle). You can move up, down, left, or right from and to an empty cell in one step. Return the minimum 00
CDChetan Dattainchetan77.hashnode.dev·Jun 7 · 2 min readFractional KnapsackProblem Given two arrays, val[] and wt[] , representing the values and weights of items, and an integer capacity representing the maximum weight a knapsack can hold, determine the maximum total value 00
CDChetan Dattainchetan77.hashnode.dev·Jan 17 · 3 min readMaximum XOR With an Element From ArrayProblem You are given an array nums consisting of non-negative integers. You are also given a queries array, where queries[i] = [x<sub>i</sub>, m<sub>i</sub>]. (link) The answer to the i<sup>th</sup> query is the maximum bitwise XOR value of x<sub>i<...00
CDChetan Dattainchetan77.hashnode.dev·Jan 15 · 2 min readMaximum XOR of Two Numbers in an ArrayProblem Given an integer array nums, return the maximum result of nums[i] XOR nums[j], where 0 <= i <= j < n. (link) Example 1: Input: nums = [3,10,5,25,2,8] Output: 28 Explanation: The maximum result is 5 XOR 25 = 28. Example 2: Input: nums = [14,7...00