Leetcode Weekly Contest 424 - Solution Discussion

Поделиться
HTML-код
  • Опубликовано: 3 дек 2024

Комментарии • 4

  • @CarlJohnson-iv7sn
    @CarlJohnson-iv7sn 17 дней назад

    Thank you! It was really helpful.

  • @rasanpreetsingh1712
    @rasanpreetsingh1712 17 дней назад +1

    could you please improve the audio quality . It would be helpful

  • @theaayushpandey_yt
    @theaayushpandey_yt 17 дней назад

    class Solution {
    public:
    int countValidSelections(vector& nums) {
    int n = nums.size(), sum = 0, currSum = 0;
    for (int i = 0; i < n; i++) {
    sum += nums[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
    if (currSum == (sum - currSum)) {ans += 2;}
    else if (abs(sum - (2 * currSum)) == 1) {ans++;}
    currSum += nums[i];
    }
    return ans;
    }
    };
    showing wrong ans for first example test case, output should be 2 but coming out to be 4, why?

  • @aryansrivastava6692
    @aryansrivastava6692 17 дней назад

    Can you provide link to your submissions codes please. Thank you