Blogs Hub

by AskGif | Jun 22, 2020 | Category :coding

Sum of Even Numbers After Queries - Array - Easy - LeetCode

Sum of Even Numbers After Queries - Array - Easy - LeetCode

We have an array A of integers, and an array queries of queries. For the i-th query val = queries[i][0], index = queries[i][1], we add val to A[index].  Then, the answer to the i-th query is the sum of the even values of A. (Here, the given index = queries[i][1] is a 0-based

read more...

by AskGif | Jun 21, 2020 | Category :coding

Add to Array-Form of Integer - Easy - LeetCode

Add to Array-Form of Integer - Easy - LeetCode

For a non-negative integer X, the array-form of X is an array of its digits in left to right order.  For example, if X = 1231, then the array form is [1,2,3,1]. Given the array-form A of a non-negative integer X, return the array-form of the integer X+K.   Exampl

read more...

by AskGif | Jun 21, 2020 | Category :coding

Available Captures for Rook - Array - Easy - LeetCode

Available Captures for Rook - Array - Easy - LeetCode

On an 8 x 8 chessboard, there is one white rook.  There also may be empty squares, white bishops, and black pawns.  These are given as characters 'R', '.', 'B', and 'p' respectively. Uppercase characters represent white pieces, and lowercase characters represent black pieces. Th

read more...

by AskGif | Jun 21, 2020 | Category :coding

XOR Operation in an Array - Easy - LeetCode

XOR Operation in an Array - Easy - LeetCode

Given an integer n and an integer start. Define an array nums where nums[i] = start + 2*i (0-indexed) and n == nums.length. Return the bitwise XOR of all elements of nums.   Example 1: Input: n = 5, start = 0 Output: 8 Explanation: Arra

read more...

by AskGif | Jun 20, 2020 | Category :coding

Find Common Characters - Array - Easy - LeetCode

Find Common Characters - Array - Easy - LeetCode

Given an array A of strings made only from lowercase letters, return a list of all characters that show up in all strings within the list (including duplicates).  For example, if a character occurs 3 times in all strings but not 4 times, you need to include that character three times in the

read more...

by AskGif | Jun 20, 2020 | Category :coding

Pairs of Songs With Total Durations Divisible by 60 - Array - Easy - LeetCode

Pairs of Songs With Total Durations Divisible by 60 - Array - Easy - LeetCode

In a list of songs, the i-th song has a duration of time[i] seconds.  Return the number of pairs of songs for which their total duration in seconds is divisible by 60.  Formally, we want the number of indices i, j such that i < j with (time[i] + time[j]) % 60 == 0. &n

read more...

by AskGif | Jun 20, 2020 | Category :coding

Partition Array Into Three Parts With Equal Sum - Easy - LeetCode

Partition Array Into Three Parts With Equal Sum - Easy - LeetCode

Given an array A of integers, return true if and only if we can partition the array into three non-empty parts with equal sums. Formally, we can partition the array if we can find indexes i+1 < j with (A[0] + A[1] + ... + A[i] == A[i+1] + A[i+2] + ... + A[j-1] == A[j] + A[j-1] + ... +

read more...

by AskGif | Jun 19, 2020 | Category :coding

Binary Prefix Divisible By 5 - Array - Easy - LeetCode

Binary Prefix Divisible By 5 - Array - Easy - LeetCode

Given an array A of 0s and 1s, consider N_i: the i-th subarray from A[0] to A[i] interpreted as a binary number (from most-significant-bit to least-significant-bit.) Return a list of booleans answer, where answer[i] is true if and only if N_i is divisible by 5.   Exam

read more...

by AskGif | Jun 19, 2020 | Category :coding

Height Checker - Array - Easy - LeetCode

Height Checker - Array - Easy - LeetCode

Students are asked to stand in non-decreasing order of heights for an annual photo. Return the minimum number of students that must move in order for all students to be standing in non-decreasing order of height. Notice that when a group of students is selected they can reorder in

read more...

by AskGif | Jun 19, 2020 | Category :coding

Duplicate Zeros - Array - Easy - LeetCode

Duplicate Zeros - Array - Easy - LeetCode

Given a fixed length array arr of integers, duplicate each occurrence of zero, shifting the remaining elements to the right. Note that elements beyond the length of the original array are not written. Do the above modifications to the input array in place, do not return anything f

read more...

by AskGif | Jun 18, 2020 | Category :coding

Relative Sort Array - Easy - LeetCode

Relative Sort Array - Easy - LeetCode

Given two arrays arr1 and arr2, the elements of arr2 are distinct, and all elements in arr2 are also in arr1. Sort the elements of arr1 such that the relative ordering of items in arr1 are the same as in arr2.  Elements that don't appear in arr2 should be placed at the end of arr1 in

read more...

by AskGif | Jun 17, 2020 | Category :coding

Final Prices With a Special Discount in a Shop - Array - Easy - LeetCode

Final Prices With a Special Discount in a Shop - Array - Easy - LeetCode

Given the array prices where prices[i] is the price of the ith item in a shop. There is a special discount for items in the shop, if you buy the ith item, then you will receive a discount equivalent to prices[j] where j is the minimum index such that j > i and prices[j] <= prices[i], otherw

read more...