LeetCode

    [LeetCode] 985. Sum of Even Numbers After Queries

    985. Sum of Even Numbers After Queries Medium You are given an integer array nums and an array queries where queries[i] = [vali, indexi]. For each query i, first, apply nums[indexi] = nums[indexi] + vali, then print the sum of the even values of nums. Return an integer array answer where answer[i] is the answer to the ith query. Example 1: Input: nums = [1,2,3,4], queries = [[1,0],[-3,1],[-4,0],..

    [LeetCode] 298. Binary Tree Longest Consecutive Sequence

    [LeetCode] 298. Binary Tree Longest Consecutive Sequence

    298. Binary Tree Longest Consecutive Sequence Medium Given the root of a binary tree, return the length of the longest consecutive sequence path. A consecutive sequence path is a path where the values increase by one along the path. Note that the path can start at any node in the tree, and you cannot go from a node to its parent in the path. Example 1: Input: root = [1,null,3,2,4,null,null,null,..

    [LeetCode] 990. Satisfiability of Equality Equations

    990. Satisfiability of Equality Equations Medium You are given an array of strings equations that represent relationships between variables where each string equations[i] is of length 4 and takes one of two different forms: "xi==yi" or "xi!=yi".Here, xi and yi are lowercase letters (not necessarily different) that represent one-letter variable names. Return true if it is possible to assign integ..

    [LeetCode] 159. Longest Substring with At Most Two Distinct Characters

    159. Longest Substring with At Most Two Distinct Characters Medium Given a string s, return the length of the longest substring that contains at most two distinct characters. Example 1: Input: s = "eceba" Output: 3 Explanation: The substring is "ece" which its length is 3. Example 2: Input: s = "ccaabbb" Output: 5 Explanation: The substring is "aabbb" which its length is 5. Constraints: 1 2: cnt..

    [LeetCode] 1680. Concatenation of Consecutive Binary Numbers

    1680. Concatenation of Consecutive Binary Numbers Medium Given an integer n, return the decimal value of the binary string formed by concatenating the binary representations of 1 to n in order, modulo 109 + 7. Example 1: Input: n = 1 Output: 1 Explanation: "1" in binary corresponds to the decimal value 1. Example 2: Input: n = 3 Output: 27 Explanation: In binary, 1, 2, and 3 corresponds to "1", ..

    [LeetCode] 1272. Remove Interval

    [LeetCode] 1272. Remove Interval

    1272. Remove Interval Medium A set of real numbers can be represented as the union of several disjoint intervals, where each interval is in the form [a, b). A real number x is in the set if one of its intervals [a, b) contains x (i.e. a

    [LeetCode] 557. Reverse Words in a String III

    557. Reverse Words in a String III Easy Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order. Example 1: Input: s = "Let's take LeetCode contest" Output: "s'teL ekat edoCteeL tsetnoc" Example 2: Input: s = "God Ding" Output: "doG gniD" Constraints: 1 str: result = split(' ', s) result = ' '.join([word[::-1] for ..

    [LeetCode]1338. Reduce Array Size to The Half

    1338. Reduce Array Size to The Half Medium You are given an integer array arr. You can choose a set of integers and remove all the occurrences of these integers in the array. Return the minimum size of the set so that at least half of the integers of the array are removed. Example 1: Input: arr = [3,3,3,3,5,5,5,2,2,7] Output: 2 Explanation: Choosing {3,7} will make the new array [5,5,5,2,2] whic..