Skip to content

Instantly share code, notes, and snippets.

View ABHIINAV12's full-sized avatar
💭
Coding .......

Abhinav Batta ABHIINAV12

💭
Coding .......
View GitHub Profile
@ABHIINAV12
ABHIINAV12 / number of islands.cpp
Created April 18, 2020 08:36
leetcode codes april contest
/*Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically. You may assume all four edges of the grid are all surrounded by water.*/
class Solution {
public:
int numIslands(vector<vector<char>>& grid) {
int r=grid.size();
if(r==0) return 0;
int c=grid[0].size();
bool vis[r][c];
class Solution {
public:
int minPathSum(vector<vector<int>>& g) {
int m=g.size();
int n=g[0].size();
for(int i=0;i<m;++i)
for(int j=0;j<n;++j){
if(i==0 && j==0)
continue;
else if(i==0){
class Solution {
public:
bool checkValidString(string s) {
int l=0,h=0;
for(char it : s){
l+= it=='(' ? 1: -1;
h+= it!= ')' ? 1: -1;
if(h<0) break;
l=max(l,0);
}
class Solution {
public:
string reformat(string s) {
int a[50]={0};
int b[56]={0};
for(char c : s){
if(c>='0' && c<='9')
++a[c-'0'];
else ++b[c-'a'];
}
class Solution {
public:
string stoi(int a){
if(a==0)
return "0";
string ret="";
while(a!=0){
int r=a%10;
a/=10;
ret+='0'+r;
/* C++ Program to search an element
in a sorted and pivoted array*/
#include <bits/stdc++.h>
using namespace std;
/* Standard Binary Search function*/
int binarySearch(int arr[], int low,
int high, int key)
{
if (high < low)
class Solution {
public:
int minNumberOfFrogs(string s) {
// c-- r-- o-- a-- k
int dp[5]={0};
int ret=0;
int op=0;
for(auto c: s){
if(c=='c'){
op++;
class Solution {
public:
int minStartValue(vector<int>& nums) {
int ret=1;
int mn=1;
for(auto it : nums){
ret+=it;
mn=min(mn,ret);
}
if(mn<1){
class Solution {
public:
int findMinFibonacciNumbers(int k) {
long long int arr[50];
arr[1]=1; arr[2]=1;
for(int i=3;i<50;++i)
arr[i]=arr[i-1]+arr[i-2];
int ret=0;
while(k!=0){
ret++;
class Solution {
public:
stack<char> st;
vector<string> sp;
void rec(int curr,int n){
if(curr==n){
string temp="";
while(!st.empty()){
temp+=st.top();
st.pop();