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 / 744_3.cpp
Created September 29, 2021 11:38
Codeforces 744 div3 solutions
void solveA(){
string s; cin>>s;
int a[3] = {};
f(i,0,sz(s)){
if(s[i]=='A') a[0]++;
else if(s[i]=='B') a[1]++;
else a[2]++;
}
bool ok = a[1] == (a[0]+a[2]);
if(ok) cout<<"YES\n"; else cout<<"NO\n";
@ABHIINAV12
ABHIINAV12 / test.cpp
Created May 15, 2021 08:11
C3 cheat sheet for data mining
// fuck this man !!
#include<bits/stdc++.h>
#include <iostream>
#include <vector>
#include <iterator>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
@ABHIINAV12
ABHIINAV12 / test.cpp
Created May 8, 2021 17:27
Atcoder Hueristic 002
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) std::begin(x), std::end(x)
using namespace std;
class xor_shift_128 {
public:
@ABHIINAV12
ABHIINAV12 / size_reducer.py
Created May 8, 2021 10:48
Image size reducer code in python
import os
import cv2
target = 'enrollment_num'
src = 'pictures'
newSize = (1024, 1024)
if os.path.isdir(target):
os.system('rm -r ' + target)
os.mkdir(target)
@ABHIINAV12
ABHIINAV12 / test.cpp
Created April 30, 2021 13:29
April challenge upsolving
--- first question :
conider the criteria of minimum surface area, for that all the cubes must be placed adjacent with side.
with number of faces visible, allot the maximum possible number to them
void solve(){
int n; cin>>n;
int four=n/4;
int rem=n%4;
int ans=four*44;
if(four!=0){
@ABHIINAV12
ABHIINAV12 / test.cpp
Created April 29, 2021 12:27
hackerearth. CFRESH. GO CSK
// divide by 2 the maximum element of array, what is the minimum maximum element you can get at end.
// question link : https://www.hackerearth.com/problem/algorithm/beautiful-division/
void solve(){
int n,k; cin>>n>>k;
bool all_zero=0;
mpi mp; f(i,0,n){
int x; cin>>x; ++mp[x];
if(x!=0) all_zero=1;
}
@ABHIINAV12
ABHIINAV12 / valid suduko.cpp
Created November 27, 2020 09:00
leetcode valid suduko
class Solution {
public:
bool isValidSudoku(vector<vector<char>>& board) {
map<char,int> mp;
for(char i='1';i<='9';++i) mp[i]=i-'0';
map<int,char> mp1;
for(int i=1;i<=9;++i) mp1[i]=i+'0';
for(int i=0;i<9;++i){
bool valid=1;
int fre[9]={0};
@ABHIINAV12
ABHIINAV12 / name.cpp
Created November 9, 2020 02:47
Given a collection of distinct integers, return all possible permutations.
class Solution {
public:
vector<vector<int>> permute(vector<int>& nums) {
vector<vector<int>> ret;
sort(nums.begin(),nums.end());
do{
ret.push_back(nums);
}while(next_permutation(nums.begin(),nums.end()));
return ret;
}
@ABHIINAV12
ABHIINAV12 / next_permutation.cpp
Created November 9, 2020 02:45
getting the next permutation
class Solution {
public:
void nextPermutation(vector<int>& nums) {
bool xp=next_permutation(nums.begin(),nums.end());
if(!xp) sort(nums.begin(),nums.end());
return ;
}
};
@ABHIINAV12
ABHIINAV12 / parenthesis.cpp
Created November 9, 2020 02:42
code for generating all valid parenthesis.
class Solution {
public:
vector<string> ret;
string s;
void rec(int a,int b){
if(a<0 || b<0 || a>b) return ;
if(a==0 && b==0) {
ret.push_back(s);
return ;
}