From 3801afa215c651efdf0dc383c9024ea632b90cd0 Mon Sep 17 00:00:00 2001 From: Devarsh Doshi Date: Mon, 6 Oct 2025 21:24:06 +0530 Subject: [PATCH 1/2] Added the Leetcode problem number 3619 --- ...lands__with_Total_Value_Divisible_By_K.cpp | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 3619_Count_Islands__with_Total_Value_Divisible_By_K.cpp diff --git a/3619_Count_Islands__with_Total_Value_Divisible_By_K.cpp b/3619_Count_Islands__with_Total_Value_Divisible_By_K.cpp new file mode 100644 index 0000000..cca6f2d --- /dev/null +++ b/3619_Count_Islands__with_Total_Value_Divisible_By_K.cpp @@ -0,0 +1,52 @@ +class Solution { +public: + int countIslands(vector>& grid, int k) { + int m=grid.size(); + int n=grid[0].size(); + int cnt=0; + vector> visited(m,vector (n)); + for(int i=0;i0){ + long long sum=0; + int a=i; + int b=j; + dfs(grid,visited,a,b,sum,m,n); + //cout<>& grid, vector> &visited, int &x,int &y, long long &sum, int m, int n){ + sum+=grid[x][y]; + //cout<0){ + int a=x-1; + if(grid[a][y]>0 &&!visited[a][y]) + dfs(grid,visited,a,y,sum,m,n); + } + if(y>0){ + int b=y-1; + if(grid[x][b]>0 &&!visited[x][b]) + dfs(grid,visited,x,b,sum,m,n); + } + + } + +}; \ No newline at end of file From e52916c5d128d461628e25c69f01211b84729aa9 Mon Sep 17 00:00:00 2001 From: Devarsh Doshi Date: Mon, 6 Oct 2025 22:11:51 +0530 Subject: [PATCH 2/2] Added the solution of leetcode problem 3495 --- ...Operations To Make Array Elements Zero.cpp | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 3495 Minimum Operations To Make Array Elements Zero.cpp diff --git a/3495 Minimum Operations To Make Array Elements Zero.cpp b/3495 Minimum Operations To Make Array Elements Zero.cpp new file mode 100644 index 0000000..3314b13 --- /dev/null +++ b/3495 Minimum Operations To Make Array Elements Zero.cpp @@ -0,0 +1,37 @@ +class Solution { +public: + long long minOperations(vector>& queries) { + long long ans=0; + for(int i=0;i3){ + log4a++; + a/=4; + } + while(b>3){ + log4b++; + b/=4; + } + if(log4a==log4b){ + ans+=((queries[i][1]-queries[i][0]+1)*log4a+1)/2; + continue; + } + long long st=pow(4,log4a); + long long end=pow(4,(log4b-1)); + long long sum=(st-queries[i][0])*log4a; + sum+=(queries[i][1]-end+1)*log4b; + log4a++; + while(log4a