Problem Description The median is the middle value in an ordered integer list. If the size of the list is even, there is no middle value and the median is the mean of the two middle values. Fo...
Last Stone Weight
Problem Description You are given an array of integers stones where stones[i] is the weight of the ith stone. We are playing a game with the stones. On each turn, we choose the heaviest two stone...
Kth Largest Element in an Array
This question is part of NeetCode150 series. Problem Description Given an integer array nums and an integer k, return the kth largest element in the array. Note that it is the kth largest element...
Reverse Bits
This question is part of NeetCode150 series. Problem Description Reverse bits of a given 32 bits unsigned integer. leetcode Solution APPROACH 1 public class Solution { public int reve...
Zigzag Traversal
Problem Description Given an m x n matrix mat, return an array of all the elements of the array in a zigzag/diagonal order. Input: mat = [[1,2,3],[4,5,6],[7,8,9]] Output: [1,2,4,7,5,3,6,8,9] lee...
Maximum AND Value
Problem Description Given an array arr[] of N positive elements. The task is to find the Maximum AND Value generated by any pair(arri, arrj) from the array such that i != j. Note: AND is bitwise ‘...
Missing Number
This question is part of NeetCode150 series. Problem Description Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from th...
Sum of XOR of all pairs
Problem Description Given an array of N integers, find the sum of xor of all pairs of numbers in the array. geeksforgeeks Solution class Solution{ // Function for finding maximum and val...
Single Number II
Problem Description Given an integer array nums where every element appears three times except for one, which appears exactly once. Find the single element and return it. You must implement a sol...
Single Number I
Problem Description Given an array of integers A, every element appears twice except for one. Find that integer that occurs once. Solution public int singleNumber(final List<Integer> A) { ...