Leetcode 0136. Single Number

Posted on Sat 15 October 2022 in Leetcode • Tagged with math

Question Link : https://leetcode.com/problems/single-number/

Difficulty: Easy

Question

Given a non-empty array of integers nums, every element appears twice except for one. Find that single one. You must implement a solution with a linear runtime complexity and use only constant extra space.   Example 1: Input: nums = [2,2 …


Continue reading

Leetcode 2433. Find The Original Array of Prefix Xor

Posted on Sun 09 October 2022 in Leetcode • Tagged with math

Question Link : https://leetcode.com/problems/find-the-original-array-of-prefix-xor/

Difficulty: Medium

Question

You are given an integer array pref of size n. Find and return the array arr of size n that satisfies:

pref[i] = arr[0] ^ arr[1] ^ ... ^ arr[i].

Note that ^ denotes the bitwise-xor operation. It can be proven that …


Continue reading

Leetcode 0462. Minimum Moves to Equal Array Elements II

Posted on Wed 29 June 2022 in Leetcode • Tagged with math

Question Link : https://leetcode.com/problems/minimum-moves-to-equal-array-elements-ii/

Difficulty: Medium

Question

Given an integer array nums of size n, return the minimum number of moves required to make all array elements equal. In one move, you can increment or decrement an element of the array by 1. Test cases are designed …


Continue reading