3K subscribers
3 photos
4 files
231 links
This channel is all about programming. Happy coding :)
Download Telegram
Today's question is EASY and should be solvable :)
Hence, no upload today.
No Video today (EASY problem)
2843. Count Symmetric Integers

CPP reference code:-
class Solution {
bool checkSymmetric(string no){
int size = no.size();
if(size&1)
return false;

int left_sum = 0;
int right_sum = 0;
for(int i=0;i<(size+1)/2;++i){
left_sum += no[i];
right_sum += no[size-i-1];
}
return left_sum==right_sum;
}
public:
int countSymmetricIntegers(int low, int high) {
int count = 0;
for(int no=low;no<=high;++no){
if(checkSymmetric(to_string(no)))
count++;
}
return count;
}
};
Interview Preparation strategy for META
1. Talk directly with Software Engineer at META
2. Get the study plan
3. Learn the challenges she faced and the effort she put on a daily basis
4. Know the preparation timeline and what worked for her
5. Get to know the difficulty level in the entire interview process for both DSA & System Design
6. Validate your approach for any future interview offer
7. Get to know the common interview preparation pitfalls for META
8. Know how the interview at META is different from other MAANG companies
9. Ask me anything is included with the session

LIVE interactive session
Limited seats only (registration will close soon)
Date: 16th April
TIME: 8 PM IST / 7:30 AM PST
Duration: 1 hour approx
Fee: 99 INR / 10 USD

CONTACT US (Whatsapp): +91 8918633037
No video today for EASY question :)
Today's problem is same as yesterday's and many last few problems.
Hence, not making video today.

REFERENCE CODE:-
class Solution {
#define ll long long
public:
long long countSubarrays(vector<int>& nums, int k) {
ll valid_subarrays = 0;
int win_count = 0;
int left = 0,right = 0;

int maximum = *max_element(nums.begin(), nums.end());
int n = nums.size();
while(left<n){
while(right<n and win_count<k){
if(nums[right]==maximum)
win_count++;
right++;
}

if(win_count==k)
valid_subarrays += n-right+1;

if(nums[left]==maximum)
win_count--;
left++;
}
return valid_subarrays;
}
};