uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
42aa4dba-832d-4ac3-afb4-ef0953813d6b | PatrikOkanovic/ETH-AlgoLab-2020 | week06/Kingdom Defence/kingdom_defence.cpp | #include <iostream>
#include <vector>
// BGL include
#include <boost/graph/adjacency_list.hpp>
// BGL flow include *NEW*
#include <boost/graph/push_relabel_max_flow.hpp>
// Graph Type with nested interior edge properties for flow algorithms
typedef boost::adjacency_list_traits<boost::vecS, boost::vecS, boost::direct... | ALGO | 0.999786 | 4.608876 |
45c1e067-72e7-4541-861a-de22284062ee | rahulll18/Recursion | subsequenceSum.cpp | #include <bits/stdc++.h>
using namespace std;
void printSum(int i, vector<int> &ds, int s, int arr[], int sum, int n)
{
if (i == n)
{
if (s == sum)
{
for (auto i : ds)
cout << i << " ";
cout << endl;
}
return;
}
// pick and a... | ALGO | 0.999681 | 4.651509 |
47bbc98f-126d-4a19-abe7-9930c72ac68c | AdminAbhi/MyCodeLib | LeetCode/String/1544. Make The String Great.cpp | class Solution {
public:
string makeGood(string s) {
int l = s.length();
string res = "";
for(int i=0; i<l; i++){
if(res.length() == 0){
res += s[i];
}
else if(abs(res.back() - s[i]) == 32){
res.pop_back();
... | ALGO | 0.999857 | 6.230896 |
163258de-7949-4bf6-8063-6b54d2303ae7 | agudpp/CordobaZombie | src/CollisionSystem/Box2D/Collision/b2Collision.cpp | #include <Box2D/Collision/b2Collision.h>
#include <Box2D/Collision/b2Distance.h>
void b2WorldManifold::Initialize(const b2Manifold* manifold,
const b2Transform& xfA, float32 radiusA,
const b2Transform& xfB, float32 radiusB)
{
if (manifold->pointCount == 0)
{
return;
}
switch (manifold->type)
{
... | ALGO | 0.998848 | 7.776567 |
8d354459-6eaf-4b6a-b32a-a0d71862732c | RicardoLopes1/Competitive_Programming | NepsAcademy/Others/1/Maquina_de_Cafe.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
ll a, b, c, tam = 3, res;
int vet[tam];
cin >> vet[0] >> vet[1] >> vet[2];
a = (vet[0]*4) + (vet[1]*2);
b = (vet[2]*4) + (vet[1]*2);
c = (vet[0]*2) + (vet[2]*2);
res = min(a, min(b, c));
cout << res ... | ALGO | 0.999773 | 4.150563 |
79aa9681-8dac-48ed-8155-0c349f27b245 | litiedan/leetcode | 342.4的幂/02test.cpp | #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class Solution {
public:
bool isPowerOfFour(int n)
{
if (n < 1) return false;
while (n % 4 == 0)
{
n /= 4;
}
return n == 1;
}
};
int main()
{
Solution s;
for(int n = 0;n<... | ALGO | 0.995072 | 4.836288 |
06af4016-433f-4c89-a115-ace8612d79f1 | Shahbaz898414/Codeforces | Practice Question/CP sheet/Implementation Constructive (105=50)/Nice Triplets02.cpp | #include <bits/stdc++.h>
using namespace std;
void findTriplet(int arr[], int n) {
int c=0;
sort(arr, arr + n);
for (int i = n - 1; i >= 0; i--) {
int j = 0;
int k = i - 1;
while (j < k) {
if ((arr[i] == arr[j] + arr[k]) and (arr[j] == arr[i] + arr[k]) && (arr[k] == arr[j] + arr[i])) {
c+... | ALGO | 0.999955 | 4.955546 |
987b810e-c899-4a65-a4ee-f04c26c65c66 | nikhil-x24/DSA_Practics | Day_57-BinarySechTree2/09-BSTfromPreorder.cpp | #include<iostream>
#include<vector>
#include<limits.h>
using namespace std;
class Node {
public:
int data;
Node* left;
Node* right;
Node(int d) {
this->data = d;
left = NULL;
right = NULL;
}
};
Node* solve(vector<int>& preorder, int mini, int maxi, int &i){... | ALGO | 0.999996 | 6.15394 |
2cd74dc8-067c-4015-8331-b40d7fe8c34f | woonki94/Algorithm | woonki/baekjoon/1463.cpp | #include<iostream>
using namespace std;
int main(){
int n;
int arr[301]={0,};
int answer[301] = {0,};
cin >> n;
for(int i=1; i<=n; i++){
cin >> arr[i];
}
answer[1] = arr[1];
answer[2] = arr[1]+ arr[2];
for(int i=3; i<= n; i++) {
answer[i] = max(arr[i - 1] + answer[i... | ALGO | 0.999976 | 3.827724 |
fcb304a0-742a-4899-889d-e3d411953a96 | pascal-the-elf/TIOJ-ASE | solutions/#01082_分堆問題.cpp | #include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#define int long long
#define pii pair<int,int>
#define ff first
#define ss second
using namespace std;
const int INF = 2e18;
int n, m, a, b, ans;
int A, B;
bool tfA, tfB;
signed main() {
ios_base::sync_with_stdio(0), cin.tie(0);
while (cin >> n) {
... | ALGO | 0.999594 | 3.82101 |
2ca2be2f-6b66-4f38-849f-36475a05acbc | ZexinYan/Leetcode | 174.cpp | #include <vector>
#include <iostream>
#include <queue>
using namespace std;
class Solution {
public:
int calculateMinimumHP(vector<vector<int>>& dungeon) {
int M = dungeon.size();
int N = dungeon[0].size();
vector<vector<int>> dp(M + 1, vector<int>(N + 1, 100000000));
dp[M][N - 1] =... | ALGO | 0.999772 | 5.577033 |
d7d55bde-3384-4404-bfd4-04737196b5fe | piyush14298/A2OJ | CodeChef/xystr.cpp | #include<bits/stdc++.h>
using namespace std;
void solve() {
string s;
cin>>s;
int i=0,j=1;
int ret =0;
while(j<s.size()) {
if(s[i] != s[j]) {
ret++;
i=j;
j++;
}
i++;
j++;
}
cout<<ret<<endl;
}
int main() {
int t;
ci... | ALGO | 0.999868 | 4.205048 |
afa28f56-30f7-4d01-be63-d65fa370baa9 | peytondmurray/megrez | mtfsim/mathutils.cpp | #include "mathutils.h"
double xyToR(double x, double y) {
return sqrt(x*x + y*y);
}
| TOOL | 0.973356 | 5.227962 |
9ba86521-f185-45be-8fb4-9cef78942171 | cicerocipriano/data_structures | pratica3_inf213/ordenaStruct1.cpp | #include <algorithm>
#include <iostream>
#include <chrono>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
using namespace std;
struct Pessoa {
string nome;
int cpf;
double altura;
};
void insertionSort_cpf(Pessoa *v, int n){
for (int i = 1; i < n; i++){
// o arranjo entre as p... | ALGO | 0.998089 | 4.758396 |
3b903ae2-9d83-40ef-8bc3-0cf34a2ff878 | NikolaDucak/neuralnet | neural_net_lib/lib/eigen-3.3.7/doc/examples/Tutorial_ReductionsVisitorsBroadcasting_broadcast_simple.cpp | #include <iostream>
#include <Eigen/Dense>
using namespace std;
int main()
{
Eigen::MatrixXf mat(2,4);
Eigen::VectorXf v(2);
mat << 1, 2, 6, 9,
3, 1, 7, 2;
v << 0,
1;
//add v to each column of m
mat.colwise() += v;
std::cout << "Broadcasting result: " << std::endl;... | ALGO | 0.996165 | 4.136906 |
828aace5-b633-49b5-8088-34e1c2ab3731 | tomriddle04/Data-Structures | Euler Path and Circuit Determination.cpp | #include<bits/stdc++.h>
using namespace std;
unordered_map<int,vector<int>> m;
bool vis[100005];
void dfs(int u)
{
vis[u]=true;
for(auto x : m[u])
{
if(!vis[x])
dfs(x);
}
}
int main()
{
int v,e;
cin>>v>>e;
int count=0,c=0;
for(int i=1;i<=e;i++)
{
int a,b;
cin>>a>>b;
m[a].push_back(b);
m[b].push_ba... | ALGO | 0.999982 | 4.088685 |
20b0dd35-21be-4cf5-aa0e-aae9b85ad9ad | liangyling3/C-- | 遍历器.cpp | /*Design a class Sparse that implements interface Matrix: Sparse should has the following public object functions in addition:
A constructor Sparse(int rows, int column), which initializes all elements in the matrix to 0's.
A copy constructor Sparse(Matrix & matrix2).
A destructor.
A print function which prints eac... | ALGO | 0.989478 | 3.747783 |
5038e183-fa63-487a-a248-e7b8235e7c39 | bitcoinanatomy/bitcoinanatomy | src/codebase/bitcoin-0.1.3 Nakamoto Institute/src/util.cpp | #include "headers.h"
bool fDebug = false;
// Init openssl library multithreading support
static HANDLE* lock_cs;
void win32_locking_callback(int mode, int type, const char* file, int line)
{
if (mode & CRYPTO_LOCK)
WaitForSingleObject(lock_cs[type], INFINITE);
else
ReleaseMutex(lock_cs[type])... | TOOL | 0.91703 | 5.04674 |
c5cfb59e-d0fa-45fa-8084-da17b6ffa926 | PaukIsUha/optimizing_formating_code | predictions/full_output_predicted_submissions/Codenet/p00545/899257714/9.cpp | #include <iostream>
#include <limits.h>
using namespace std;
using ll = long long;
const ll MIN = -(LONG_LONG_MAX - 1);
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int N, Q;
ll T;
cin >> N >> T >> Q;
ll people[1001];
ll A[100001];
int D[100001];
for (int i = 0; i < N; i++... | ALGO | 0.999931 | 3.63464 |
c91febd4-d6a4-4fec-b811-1779cedc981f | sky-bro/AC | leetcode.com/0712 Minimum ASCII Delete Sum for Two Strings/main.cpp | #include <iostream>
#include <numeric>
#include <vector>
using namespace std;
class Solution {
private:
int n1, n2;
string s1, s2;
int dfs(int i, int j, vector<vector<int>>& dp) {
if (i == n1 || j == n2) return 0;
if (~dp[i][j]) return dp[i][j];
int res;
if (s1[i] == s2[j]) {
res = 2 * s1... | ALGO | 0.999957 | 5.759062 |
dc46a5a4-87a4-420c-823b-d38572d8a3ac | jcllanu/Doble-Grado-Informatica-Matematicas | 2º Carrera/Segundo Cuatrimestre/Estructuras de Datos/Ejericios/Estructuras lineales/Intercambiar de 2 en 2/solucion.cpp |
// JUAN CARLOS LLAMAS NEZ
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include "colaHeredada.h"
#include"queue.h"
using namespace std;
bool resuelveCaso() {
ColaIntercambiar<int> cola;
int aux,n;
cin >> n;
if (n==0) {
return false;
}
for(int i=0; i<n; i++){
cin >> aux;
... | ALGO | 0.99966 | 4.737508 |
0ca709e6-98d4-4617-852d-08894c607c65 | algoplutus1708/Competitive-Programming-Solutions | Codeforces/1602 - Round #751 (Div. 2)/C. Array Elimination.cpp | /*** KNOWLEDGE IS POWER ***/
#include<bits/stdc++.h>
typedef long long ll ;
#define int ll
#define pb push_back
#define all(v) v.begin(),v.end()
#define mod 1000000007
#define inf LLONG_MAX
using namespace std ;
void solve( )
{
int n ;
cin >> n ;
vector<int> a(31 , 0) ;
for(int i = 0 ; i < n ; i++)
{
int x ;... | ALGO | 0.999829 | 4.00311 |
3cf272d7-c873-4615-8b2b-346e134b6fff | mathnantes/uri-solutions-cpp | 1070.cpp | #include <iostream>
using namespace std;
int
main()
{
int x, i=0;
cin >> x;
while (i<6)
{
if(x%2 != 0)
{
cout << x << endl;
i++;
}
x++;
}
return 0;
}
| ALGO | 0.998876 | 3.021583 |
2a31bc3b-4ce6-45d9-8f86-3ba6d24ffa0a | Aryan2727-debug/Love-Babbar-DSA-Problems | Detect_loop_in_LL.cpp | #include <iostream>
#include <bits/stdc++.h>
using namespace std;
struct Node{
int data;
struct Node* next;
int flag;
};
void LinkedListTraversal(struct Node* ptr){
while(ptr!=NULL){
cout<<ptr->data<<"->";
ptr=ptr->next;
}
if(ptr==NULL){
cout<<"NULL";
}
}
bool detectL... | ALGO | 0.999909 | 4.192838 |
9b1791ac-c643-45c1-9d32-90e05b9f04fc | Vedansh1857/Cpp | cpp/new and delete keyword.cpp | #include<iostream>
using namespace std;
int main()
{
/*int a = 4;
int *ptr = &a;
cout<<"The value of a is : "<<*ptr<<endl;*/
// int *ptr = new int(40);
// cout<<"The value at address of ptr is : "<<*ptr<<endl;
int *arr = new int[3];
*arr = 10;
arr[1] = 20;
arr[2] = 30;
// dele... | ALGO | 0.925755 | 3.184071 |
4c2f0b56-8ace-4a96-bed1-945c2ae72e68 | Chep-Code-lo/LUYEN_CODE | NHAP_MON_LAP_TRINH_UTE_OJ/MT1-Array1D-202211-24-Bai4.cpp | #include <bits/stdc++.h>
using namespace std;
typedef vector<int> bigInt;
const int BASE = 1000;
const int LENGTH = 3;
bigInt& fix(bigInt &a) {
a.push_back(0);
for (int i = 0; i + 1 < a.size(); ++i) {
a[i + 1] += a[i] / BASE; a[i] %= BASE;
if (a[i] < 0) a[i] += BASE, --a[i + 1];
}
while (a.size() > 1 ... | ALGO | 0.999952 | 4.252692 |
b38fd5cc-9012-4ebe-8175-c4af6d513689 | OblivionNoirV2/sakura | CMakeProject1/sakura.cpp | #include "sakura.h"
#include <vector>
#include <algorithm> // For std::copy
#include <iostream>
#include <array>
using namespace std;
//SAKURA
//S -> A
//A -> S or K or R
//K -> A or U
//U -> K or R
//R -> U or A
//A -> S or K or R
int turn_counter = 1;
string display_message(string message)
{
return messag... | ALGO | 0.990605 | 4.525761 |
66cec283-3b46-436b-bfc5-ef7cbf1ebe2e | Zhaisan/ads | basicsOF_c++(not algo course)/extrainf/informatics/extra1_BC.cpp | //Факториал
#include <iostream>
using namespace std;
int main(){
int n, s=1, i;
cin>>n;
for (i=1; i<=n; ++i)
{
s=s*i;
}
cout<<s<<endl;
} | ALGO | 0.999971 | 4.816566 |
aead367e-828c-420a-b32b-87827d088b0e | sanyamdtu/Leetcode | solutions/303. Range Sum Query - Immutable.cpp | class NumArray {
public:
int prefix[100000];
NumArray(vector<int>& arr) {
int n=arr.size();
if(n!=0){
prefix[0]=arr[0];
for(int i=1;i<n;i++){
prefix[i]=prefix[i-1]+arr[i];
}
}
}
int sumRange(int i, int j) {
... | ALGO | 0.999812 | 6.288732 |
dba47f31-7880-4c87-8e5c-7c37a18d0edb | pah-10/Studies-C-Plus-Plus | exe propostos/exe22Propostos.cpp | //Exercicio 22 dos exercicios propostos
//Programa que recebe a idade e o peso de algum e verifica em qual grupo de risco a pessoa se encaixa
#include <iostream>
using namespace std;
int main() {
float peso, idade;
cout<<"Informe a sua idade"<<endl;
cin>>idade;
cout<<"Informe o seu peso"<<endl;
cin>>peso;
... | ALGO | 0.998083 | 3.625395 |
58f4a2f9-5300-40f7-8df6-950acf9fb08b | ndhuanhuan/16_coding_practice | 1001-1200/1094. Car Pooling.cpp | // https://zxi.mytechroad.com/blog/heap/leetcode-1094-car-pooling/
class Solution {
public:
bool carPooling(vector<vector<int>>& trips, int capacity) {
vector<int> d(1001);
for (const auto& trip : trips) {
d[trip[1]] -= trip[0];
d[trip[2]] += trip[0];
}
for (const int c : d)
if ((ca... | ALGO | 0.99655 | 6.680123 |
aba5d73e-23ac-41b4-88b7-8f575087f38d | RashmiMaxCoder/Data-Structure | linklist/FirstNonRepeating.cpp | string FirstNonRepeating(string A){
// Code here
vector<int> vis(26,0);
string res="";
vector<char> seq;
int n = A.length();
for(int i = 0; i < n; i++)
{
if(!vis[A[i] - 'a'])
{
seq.push_back(A[i]);
}
vi... | ALGO | 0.999931 | 3.801511 |
fa7193bf-1299-4bb4-a3fb-0ec084a7dd35 | typr7/practice | anything/Trees_on_the_level1.cpp | /* UVa 122 树的层次遍历*/
#include<iostream>
#include<cstring>
#include<queue>
#include<vector>
using namespace std;
struct Node {
bool have_value;
int value;
Node* left, * right;
Node() :have_value(false), left(NULL), right(NULL) {};
};
Node* root = new Node();
vector<Node*> q;
bool CanPrint() {
Node* t... | ALGO | 0.999851 | 3.523602 |
3c92b1ba-eb82-42e5-9b1d-58e5dc95a822 | tienvuiet/tienvuviet_C_session10 | basic2.cpp | #include<stdio.h>
int main(){
int a[]={23,2,32,232,1};
int n=sizeof(a)/sizeof(a[0]);
for(int i=0;i<n-1;i++){
for(int j=0;j<n-i-1;j++){
if(a[j]>a[j+1]){
int temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
}
}
}
printf("mang sau khi duoc xap xep la: ");
for(int i=0;i<n;i++){
... | ALGO | 0.999771 | 3.160756 |
8253307e-f9bc-4e95-a28a-3b9ccdb57518 | MilkClouds/Competitive-Programming | BOJ/milkclouds/02342/2342.cpp14.cpp | # pragma GCC optimize ("O3")
# pragma GCC optimize ("Ofast")
# pragma GCC optimize ("unroll-loops")
# include <bits/stdc++.h>
# define rep(a,b,c) for(int a=b;a<c;a++)
# define x first
# define y second
# define all(x) x.begin(),x.end()
# define pb push_back
using namespace std;
using ll=long long;
using pii=... | ALGO | 0.999831 | 4.412535 |
88616754-a814-4cf3-9a4b-566b2270a0ae | kta20/Tarea2_EDa | tarea2/basura_porsiaca/cola_enemigos.cpp | #include "cola_enemigos.hpp"
cola_enemigo* crear_cola() {
return NULL;
}
void encolar(cola_enemigo*& frente, cola_enemigo*& fin, enemigo* e) {
cola_enemigo* nuevo = new cola_enemigo;
nuevo->dato = e;
nuevo->sig = NULL;
if (fin) {
fin->sig = nuevo;
} else {
frente = nuevo;
}... | TOOL | 0.938197 | 4.033122 |
6e2f7c7e-c016-449c-946b-485aa836e7db | ishaankalsi/All_algos_ds_needed | code/data_structures/stack/reverse_stack/reverse_stack_without_extra_space.cpp | /*
* Part of Cosmos by OpenGenus Foundation
*/
#include <iostream>
#include <stack>
using namespace std;
void InputElements(stack<int> &s){
//no. of elements to be inserted
int size;
cin>>size;
while(size--){
int num;
cin>>num;
s.push(num);
}
}
void InsertInStack(stack<int... | ALGO | 0.999868 | 5.45993 |
2e380723-3412-4715-b682-18128dda6587 | MKshenchen/CppLearn | 代码示例/排序算法/shellSort.cpp | #include <iostream>
using namespace std;
// void swap(int *, int *);
void showUnderLine();
void showArrayElement(int *arrPtr, int arrLen);
void shellSort(int *arrPtr, int arrLen);
int main()
{
int arr[]{1, 9, 2, 6, 8, 0, 7};
showArrayElement(arr, 7);
shellSort(arr, 7);
showArrayElement(arr, 7);
... | ALGO | 0.999719 | 3.846992 |
84a0d1fc-816e-4789-a31f-a61b7424ee64 | shreyabrruuh/online- | compiler/code/cpp/ef56633b-f169-45f1-bb72-ca001cba7c00.cpp | #include <iostream>
#include<string>
using namespace std;
bool isPalindrome(string s) {
int n=s.length();
int left=0;
int right=n-1;
while(left<right){
if(!isalnum(s[left])){
left++;
continue;
}
if(!isalnum(s[right])){... | ALGO | 0.999798 | 5.490076 |
a32de6d7-721c-4078-a1d0-a06da0c91ec1 | xseifert/UE4-GameWorks | Engine/Source/ThirdParty/IntelEmbree/Embree270/src/kernels/xeonphi/bvh4i/bvh4i_intersector16_hybrid.cpp | #include "bvh4i_intersector16_hybrid.h"
#include "bvh4i_leaf_intersector.h"
#define SWITCH_ON_DOWN_TRAVERSAL 1
namespace embree
{
namespace isa
{
static unsigned int BVH4I_LEAF_MASK = BVH4i::leaf_mask; // needed due to compiler efficiency bug
template<typename LeafIntersector, bool ENABLE_COMPRESSED_BVH4... | ALGO | 0.999602 | 7.16909 |
e2bbd449-c6a6-4771-8bfd-422b12d37c1f | bendavid/firmware-mod-kit | src/others/squashfs-3.4-cisco/lzma/CPP/7zip/Compress/ByteSwap.cpp | // ByteSwap.cpp
#include "StdAfx.h"
#include "ByteSwap.h"
STDMETHODIMP CByteSwap2::Init() { return S_OK; }
STDMETHODIMP_(UInt32) CByteSwap2::Filter(Byte *data, UInt32 size)
{
const UInt32 kStep = 2;
UInt32 i;
for (i = 0; i + kStep <= size; i += kStep)
{
Byte b = data[i];
data[i] = data[i + 1];
d... | ALGO | 0.953007 | 5.358013 |
2e5c5dbe-77b5-4d65-826d-c683468955e6 | GouriBiswas/DSA-problems | DSA CODEHELP/Lecture54_ STACK/stackWithoutSTL.cpp | #include<iostream>
#include<stack>
using namespace std;
class Stack {
//properties
public:
int *arr;
int top;
int size;
// behaviour
Stack(int size) {
this -> size = size;
arr = new int[size];
top = -1;
}
void push( int element) {
if(siz... | ALGO | 0.998152 | 4.310053 |
4584b83e-5e53-48d2-89b5-857c5828d607 | LongSei/Competitive-Training | VOJ - DEMSO.cpp | #include<bits/stdc++.h>
using namespace std;
#define int long long
#define faster ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int INF = 1e9 + 7;
int A,B,D,K, n[30];
// (position, number_ugly, last_digit, lower, positive)
const int MAX = 30;
int dp[MAX][MAX][10][2][2];
int f(int N, int d, int k) {
ve... | ALGO | 0.999789 | 4.031108 |
dfaf22fd-0161-4174-9262-28c9dbd8db4a | AyushJ16/leetcode | 1157-insufficient-nodes-in-root-to-leaf-paths/1157-insufficient-nodes-in-root-to-leaf-paths.cpp | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode() : val(0), left(nullptr), right(nullptr) {}
* TreeNode(int x) : val(x), left(nullptr), right(nullptr) {}
* TreeNode(int x, TreeNode *left, TreeNode *right) : val(x), l... | ALGO | 0.999994 | 6.223783 |
586cf3e6-2271-4c98-927f-30ac90d36309 | danielnieuwerf/LeetcodeSubmissions | 2192-all-ancestors-of-a-node-in-a-directed-acyclic-graph/2192-all-ancestors-of-a-node-in-a-directed-acyclic-graph.cpp | class Solution {
vector<vector<int>> dp;
vector<bool> computed;
unordered_map<int, vector<int>> mp;
public:
vector<vector<int>> getAncestors(int n, vector<vector<int>>& edges) {
dp = vector<vector<int>>(n, vector<int>(1, -1));
computed = vector<bool>(n, false);
for(auto edge... | ALGO | 0.999996 | 6.218778 |
a753d75c-e94e-4678-a949-f2a54bdb585d | RndmRyan/LeetCode-Collection | 2244-number-of-laser-beams-in-a-bank/number-of-laser-beams-in-a-bank.cpp | using namespace std;
class Solution {
public:
int numberOfBeams(vector<string>& bank)
{
vector<int> devices;
for (int i = 0; i < bank.size(); i++)
{
int count = 0;
for (char c : bank[i])
if (c == '1')
count++;
... | ALGO | 0.999959 | 6.35751 |
31b0b74f-61d2-4eb9-99aa-5316d6c00d02 | kapoorz/cpptopics | swe/spiralmatrix.cpp | #include <bits/stdc++.h>
using namespace std;
vector<int> spiralOrder(vector<vector<int>> &matrix)
{
vector<int> ans;
int dir = 0;
int t = 0, b = matrix.size() - 1, l = 0, r = matrix[0].size() - 1;
while (l <= r && t <= b)
{
if (dir == 0) // right
{
for (int i = l; i <=... | ALGO | 0.999991 | 5.043776 |
878360e2-bed5-4773-b51e-817de85985e5 | sugatbhagat20/love-babbar-DSA-cracker | merge2array.cpp | //Merge 2 sorted arrays without using Extra space.
#include <bits/stdc++.h>
using namespace std;
void mergeArray(int a[], int b[], int x, int y)
{
for (int i = 0; i < x; i++)
{
if (a[i] > b[0])
{
swap(a[i], b[0]);
}
sort(b, b + y);
}
for (int i = 0; i < x; i... | ALGO | 0.999977 | 5.518797 |
3f0e4362-a7b0-4325-a2f2-1b3613ac776d | thoomi/CarND-Path-Planning-Project | src/Eigen-3.3/doc/snippets/MatrixBase_all.cpp | Vector3f boxMin(Vector3f::Zero()), boxMax(Vector3f::Ones());
Vector3f p0 = Vector3f::Random(), p1 = Vector3f::Random().cwiseAbs();
// let's check if p0 and p1 are inside the axis aligned box defined by the corners boxMin,boxMax:
cout << "Is (" << p0.transpose() << ") inside the box: "
<< ((boxMin.array()<p0.array(... | ALGO | 0.971752 | 3.51303 |
2071e096-2ba7-4cd0-ad68-4a5fc8c6bcd5 | fhvirus/CodeArchive | TIOJ/1368.cpp | #pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma loop_opt(on)
#include<cstdio>
#define FOR(i,n) for(int i=0;i<n;++i)
const int S = 1<<20;
inline char readchar(){
static char buf[S], *p = buf, *q = buf;
return (p==q... | ALGO | 0.998562 | 3.484162 |
df430fc7-5f0c-4393-b9d6-c73e7ac19e36 | Bowman7/DSA | c++/quicksort.cpp | #include<iostream>
using namespace std;
void swap(char* a, char* b){
char temp;
temp = *a;
*a =*b;
*b = temp;
}
void swap(int* a,int* b){
int temp;
temp = *a;
*a = *b;
*b =temp;
}
int partition(string array,int low,int high){
int pivot = array[high];
int i=(low-1);
f... | ALGO | 0.99993 | 4.732213 |
e3d50028-8442-4ae5-8971-abcbb464b028 | mirzaazwad/CSE4403-Data-Structures-And-CSE4404-Algorithms | Algorithms/Implementation&Problems/Implementations/Graph Theory/Implementations/FloodfillAndConnectedComponentCheck.cpp | #include<bits/stdc++.h>
using namespace std;
int n, m;
int dirx[] = {-1, 0, 1, 0};
int diry[] = {0, 1, 0, -1};
bool visited[102][102];
int color[102][102];
string grid[102];
int sectorSize(int x, int y)
{
cout << x << " " << y << "\n";
int ret = 1;
visited[x][y] = 1;
for(int i = 0; i < 4; i++)
... | ALGO | 0.999949 | 4.94213 |
3cfc5cf2-52fb-441d-b8e2-e3f19ba6eb2c | Apurba94/10-Years-of_Competitive-Programming-Resources-Collection | UVA/Contest Volumes/11526 - H(n).cpp | #include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
long long f(int n){
if(n==0) return 0;
long long ans = 0;
int i,r = (int)floor(sqrt(n));
if(r*r==n){
ans += n/r;
--r;
}
for(i = 1;i<=r;++i){
ans += n/i;
ans += max(0,n/i-r);
... | ALGO | 0.999864 | 4.93525 |
48221dd5-075e-491c-8f90-8b5e45ef12be | langningchen/XMOJ | UnAC/1830.cpp | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 30005;
ll n, m, f[N], s[N];
ll find(ll x)
{
if (f[x] == x)
return x;
ll t = f[x];
f[x] = find(f[x]);
s[x] += s[t];
return f[x];
}
int main()
{
scanf("%lld%lld", &n, &m);
for (ll i = 1; i <= n; i++)
... | ALGO | 0.999915 | 4.038464 |
abe275ed-3d59-4d56-95ed-426de58add42 | sourabhjain9887/6Companies30Days- | GlodmanSachs/Decode the-string .cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin >> s;
string num = "";
string ans = "";
int n;
string temp = "";
string temp2 = "";
stack<char> st;
int p = 0;
while (p < s.size())
{
if (s[p] == ']')
{
while (st.top() != '... | ALGO | 0.999701 | 4.853375 |
06c222d8-555a-480c-a849-6b392d5e2a06 | iashu-777/cpp-prgramming-language | A_Flipping_Game.cpp | #include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 998244353
#define loop(a,b,c) for(ll i=a;i<b;i+=c)
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n;
cin>>n;
vector<ll>v;
ll zero=0;
ll ones=0;
loop(0,n,1){
ll x;
cin>>x;
v.pus... | ALGO | 0.999996 | 4.468817 |
29026c88-b725-41a6-b948-bcdf5c0d0c5c | MyeonghoonNam/coding-test-with-cpp | 문제/정수론/3474.cpp | #include <bits/stdc++.h>
using namespace std;
int T, N;
int ret2, ret5;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> T;
while (T--) {
cin >> N;
ret2 = 0;
ret5 = 0;
for (int i = 2; i <= N; i *= 2) {
ret2 += N / i;
}
for (int i = 5; i ... | ALGO | 0.999873 | 5.324792 |
aae4ff0a-ef12-4036-9819-b81ebbc050d6 | gautam5722/DSA-PRACTICE-BY-ME | GFG/Rotate by 90 degree/Solution.cpp | /*
Question :- https://practice.geeksforgeeks.org/problems/rotate-by-90-degree-1587115621/1
Solution
*/
//{ Driver Code Starts
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
class Solution
{
public:
//Function to rotate matrix anticlockwise by 90 degrees.
void rotateby90(vector<... | ALGO | 0.999933 | 5.932409 |
12ec2ede-465e-4a0b-a574-e9ca5cfd887d | AndreiZherder/cpp-practice | func10.cpp | /*Возводить в степень можно гораздо быстрее, чем за n умножений! Для этого нужно воспользоваться следующими рекуррентными соотношениями:
a^n = (a^2)^(n/2) при четном n,
a^n = a × a^(n−1) при нечетном n.
Реализуйте алгоритм быстрого возведения в степень с помощью рекурсивной функции.
Формат входных данных
Вводятся ... | ALGO | 0.99998 | 5.287863 |
398a5f43-090f-4613-96bd-b49bb0429d88 | Prateek-Khachi/CPP | new.cpp | class Solution
{
public:
string minWindow(string s, string t)
{
if (t.size() > s.size())
{
return "";
}
map<char, int> mapT; // Frequency map for string t
map<char, int> mapS; // Frequency map for current window in s
// Initialize the frequency map f... | ALGO | 0.999997 | 7.323412 |
6de236b2-1e4c-4476-b5dd-4024195026ad | Abhishekkute234/Data-Structure-and-Algorithm-in-CPP | 8_recurssion_CPP/8_saties.cpp | // numbers of ways to recah the n staire
// to have n numbers of staires
// take one or two step to go to 0 to n
#include<iostream>
using namespace std;
int stair(int n){
if(n==0){
return 1;
}
if(n<0){
return 0;
}
else {
return stair(n-1)+stair(n-2);
}
}
int main(){
... | ALGO | 0.999981 | 4.078431 |
39632557-c12f-4e58-9195-968a9533625e | CommanderG6/system_vold | Utils.cpp | #include "Utils.h"
#include "Process.h"
#include "sehandle.h"
#include <android-base/file.h>
#include <android-base/logging.h>
#include <android-base/properties.h>
#include <android-base/strings.h>
#include <android-base/stringprintf.h>
#include <cutils/fs.h>
#include <logwrap/logwrap.h>
#include <private/android_fil... | TOOL | 0.985074 | 7.24016 |
3e604b47-7545-491b-b30d-944939197531 | jayeshborase/Leetcode_solution | 1791-find-center-of-star-graph/1791-find-center-of-star-graph.cpp | class Solution {
public:
int findCenter(vector<vector<int>>& edges) {
// vector<vector<int>> adj(edges.size()+2);
// for(auto i : edges){
// adj[i[0]].push_back(i[1]);
// adj[i[1]].push_back(i[0]);
// }
// int mx = 0;
// int ans = 0;
... | ALGO | 0.999965 | 5.421859 |
00ae627b-f401-404e-920f-1ff4a117fd7d | miiitomi/atcoder | ABC/abc240/b.cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int N;
cin >> N;
set<int> S;
for (int i = 0; i < N; i++) {
int a;
cin >> a;
S.insert(a);
}
cout << (int)S.size() << endl;
}
| ALGO | 0.999171 | 4.22413 |
04d09df7-2ef1-4fbc-a060-2624d65c2a10 | colin-arnet/DSL-crypto-bench-tls | Vitis_Libraries/vision/L2/examples/fast/xf_fast_tb.cpp | #include "common/xf_headers.hpp"
#include "xcl2.hpp"
#include "xf_fast_config.h"
#include <time.h>
int main(int argc, char** argv) {
if (argc != 2) {
fprintf(stderr, "Usage: %s <INPUT IMAGE PATH 1>\n", argv[0]);
return EXIT_FAILURE;
}
cv::Mat in_gray, out_img, out_img_ocv, out_hls;
/... | ALGO | 0.870232 | 6.004372 |
fc77b9ab-e106-4790-8932-b61a0d71cac2 | Jcamiloag/Proyecto_moviles | windows/runner/utils.cpp | #include "utils.h"
#include <flutter_windows.h>
#include <io.h>
#include <stdio.h>
#include <windows.h>
#include <iostream>
void CreateAndAttachConsole() {
if (::AllocConsole()) {
FILE *unused;
if (freopen_s(&unused, "CONOUT$", "w", stdout)) {
_dup2(_fileno(stdout), 1);
}
if (freopen_s(&unuse... | TOOL | 0.998733 | 6.76775 |
86fcbbad-8c0e-40ac-bd68-78217ad9de7d | mrvivekthumar/DSA-PROBLEM | Recursion & Backtracking/Section-1/binary_Search.cpp | #include <bits/stdc++.h>
#include <iostream>
using namespace std;
int binarySearch_recursion(int a[], int start, int end, int key)
{
int mid = start + (end - start) / 2;
// base case
if (a[mid] == key)
{
return mid;
}
// rec case
if (key > a[mid])
{
return binarySearch_... | ALGO | 0.999744 | 5.049334 |
c247463d-3429-4fcb-82cd-84bb4477197c | ishandutta2007/codeforces | karry5307/normal/1081/C.cpp | #include<bits/stdc++.h>
using namespace std;
typedef int ll;
typedef long long int li;
const ll MAXN=2e5+51,MOD=998244353;
ll n,m,kk;
ll fact[MAXN],finv[MAXN];
inline ll read()
{
register ll num=0,neg=1;
register char ch=getchar();
while(!isdigit(ch)&&ch!='-')
{
ch=getchar();
}
if(ch=='-... | ALGO | 0.99998 | 4.456021 |
a953ccfd-5ac2-4445-987c-4788fe0a197d | jrojer/sport | trash/problems/matrices/gauss/upper_triangle.cpp | #include <iostream>
#include <vector>
#include <algorithm>
using row_t = std::vector<double>;
using matr_t = std::vector<row_t>;
static const double eps = 0.00001;
matr_t ToUpperTriangle(const matr_t& matrix)
{
auto M = matrix;
const size_t nrows = M.size();
const size_t ncols = M.begin()->size();
f... | ALGO | 0.999918 | 3.260358 |
29f65977-69f2-4f6b-8c01-4ebc02fdacd0 | AshishTiwari1203/Cpp-Coding | array/str1.cpp | #include <iostream>
#include <string>
using namespace std;
// Converting ch to lower case
/*char lower_case(char ch)
{
if (ch >= 'a' && ch <= 'z')
{
return ch;
}
else
{
return ch - 'A' + 'a';
}
}
// converting ch to uppercase
void upper_case(char var)
{
if (var >= 'A' && va... | ALGO | 0.96881 | 4.206568 |
7b8a4dce-f8a8-4ef5-a33d-600742c096b8 | alexeyorehoff/cv-lessons | lab3/lab3_2.cpp | #include "opencv2/core.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/videoio.hpp"
#include <vector>
#include <iostream>
static int threshold_level = 50;
cv::Mat original;
cv::VideoCapture cap;
cv::Mat detect(cv::Mat img) {
cv::Mat hsv;
cv... | TOOL | 0.870349 | 4.603779 |
2cadfc6b-21ba-4fa9-b373-2e90706fc8bd | derek-zr/leetcode | Solution/538-convert-bst-to-greater-tree/convert-bst-to-greater-tree.cpp | // Given the root of a Binary Search Tree (BST), convert it to a Greater Tree such that every key of the original BST is changed to the original key plus sum of all keys greater than the original key in BST.
//
// As a reminder, a binary search tree is a tree that satisfies these constraints:
//
//
// The left subtree... | ALGO | 0.999989 | 6.183827 |
ff958129-f838-44af-8a1e-5c6128d34ba4 | MinahilMJ/Programming-Fundamentals | PF_LAB_12/PF_P02_LAB12.cpp | #include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
string text;
string word;
int text_length, found=-1;
cout<<"Enter the Text ";
getline(cin, text);
text_length=text.length();
cout<<"Enter the Word ";
cin>>word;
for(int i=0; i<text.length();i++)
{
if(t... | ALGO | 0.997279 | 4.602372 |
0915623a-620c-4768-ad9a-c89154ef190a | chiquibitrian/lammps-induced-dipole-polarization-pair-style | lib/gpu/lal_yukawa_ext.cpp | /***************************************************************************
yukawa_ext.cpp
-------------------
Trung Dac Nguyen (ORNL)
Functions for LAMMPS access to yukawa acceleration routines.
_______________________________... | TOOL | 0.881026 | 5.69729 |
e27d8a8b-7199-4c4c-bdb1-bba2ffcac9c8 | SIDLAD/CC | c and cpp codes/practice folder/C_Beautiful_Sequence.cpp | #include <bits/stdc++.h>
const long double EPS = 1e-10;
const long long int M = (long long int) 998'244'353;
using namespace std;
//insert policy here
//insert mintcode here
//insert randnum here
#if defined (ONLINE_JUDGE) || !__has_include (</home/sidlad/Desktop/Coding Folder/c and cpp codes/Debug.h>)
void _exe... | ALGO | 0.999765 | 4.344672 |
04146751-bd69-4f3e-812d-bed196a6a2f4 | kjtm03/clase1 | point/src/geometry.cpp | #include "geometry.h"
#include <cstddef>
PointArray :: PointArray () {
size = 0;
points = new Point [0];
}
PointArray :: PointArray ( const Point ptsToCopy [], const int toCopySize
) {
size = toCopySize ;
points = new Point [ toCopySize ];
for ( int i = 0; i < toCopySize ; ++i) {
points [i] = ptsToCopy... | TOOL | 0.961597 | 4.015901 |
22e5f111-e2be-4656-aede-2096ffb97c42 | Ridho626/Strukdat | Final Project/Adj List.cpp | #include<bits/stdc++.h>
using namespace std;
class Graph {
private:
int v;
string nama[100];
vector<list<int>> adj;
map<pair<int,int>, int> weight;
vector<int> dfsResult;
int dfsWeight;
vector<int> dijkstraRes;
public:
Graph(int v) {
t... | ALGO | 0.999786 | 4.373014 |
5a8aec81-fc7f-4de6-9a10-6792e4adc247 | Cole-Resetco/schoolWork-C9 | CS12/cs012_practice/Labs/lab10/main.cpp | #include <iostream>
#include <cstdlib>
using namespace std;
void reverse (string &s)
{
if(s.size() == 0)
{
return;
}
else
{
//cout << "starting recurstion" << endl;
//cout << "this is the string: " << s << ", this is the size: " << s.size() << endl;
cout << s.a... | ALGO | 0.985956 | 4.764305 |
55546443-29ad-4ea7-b21d-7e6ed003211d | Aikoin/Algorithm | 交换迭代器指向值iter_swap.cpp | // iter_swap example
#include <iostream> // std::cout
#include <algorithm> // std::iter_swap
#include <vector> // std::vector
int main () {
int myints[]={10,20,30,40,50 }; // myints: 10 20 30 40 50
std::vector<int> myvector (4,99); // myvector: 99 99 99 99
std::i... | ALGO | 0.995558 | 4.813453 |
508c2507-e0f2-4b76-b45b-00d60325489e | Pragna235/Coding_Ninjas_Slayground_2023 | Sum Of Max and Min.cpp | #include <bits/stdc++.h>
int sumOfMaxMin(int arr[], int n){
// Write your code here.
int maxi=INT_MIN;
int mini=INT_MAX;
for(int i=0;i<n;i++){
maxi=max(maxi,arr[i]);
mini=min(mini,arr[i]);
}
return maxi+mini;
}
| ALGO | 0.999941 | 5.254422 |
82e390fc-4be0-4f2d-be0f-5fc60c640c5a | KhanSonet/urionlinejudge.com.br | prob_1041.cpp | #include<iostream>
#include<cstdio>
using namespace std;
int main ()
{
float x,y;
cin>>x>>y;
if ( x==0 && y==0)
{
cout<<"Origem"<<endl;
}
else if (x == 0.0 && y != 0.0)
cout<<"Eixo Y"<<endl;
else if (y == 0.0 && x != 0.0)
cout<<"Eixo X"<<endl;
else if ( x>0 &... | ALGO | 0.999713 | 3.475564 |
1872c6b8-8d82-4d39-9b18-f949abd2d115 | kochkozharov/competitive-progamming | summer_practice/04.07.23/contest/c.cpp | #include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <cmath>
using namespace std;
using ll= long long;
int main() {
cin.tie(0); cout.tie(0);
ios_base::sync_with_stdio(false);
ll n, m, k;
cin >> n >> m >> k;
vector<vector<ll>> r(n+1, vector<ll>(m+1, -1));
whi... | ALGO | 0.999984 | 4.609465 |
cf479189-e53f-47d7-8db3-ebbbc252717e | jacksonwildemurphy/Learn2Code | LearnToCode/lib/Box2D-master/Box2D/Box2D/Dynamics/Joints/b2FrictionJoint.cpp | #include <Box2D/Dynamics/Joints/b2FrictionJoint.h>
#include <Box2D/Dynamics/b2Body.h>
#include <Box2D/Dynamics/b2TimeStep.h>
// Point-to-point constraint
// Cdot = v2 - v1
// = v2 + cross(w2, r2) - v1 - cross(w1, r1)
// J = [-I -r1_skew I r2_skew ]
// Identity used:
// w k % (rx i + ry j) = w * (-ry i + rx j)
//... | ALGO | 0.987365 | 7.570709 |
4f3c3541-9c7b-424d-ba4a-54783600aa7e | Akrobatik/ps | BaekJoon/33000/33692.cpp | // Title : 해밍거리
// Link : https://www.acmicpc.net/problem/33692
// Time : 0 ms
// Memory: 2020 KB
#include <bits/stdc++.h>
using namespace std;
constexpr int64_t kMax = 1e18;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int64_t a, b;
cin >> a >> b;
int64_t aa = a, bb = b;
for (int64_t ... | ALGO | 0.999977 | 4.418544 |
ea16a5d8-ec60-45e4-868e-0bdecfbf1c51 | haakoan/wavelets | cpp/libdwt-2015-02-18-dev/src/cvdwt.cpp | /**
* @file
* @author David Barina <<EMAIL>>
* @brief OpenCV interface to libdwt.
*/
#include "cvdwt.h"
#include "libdwt.h"
#include <highgui.h> // imshow
using namespace cv;
using namespace dwt;
void dwt::resizePOT(
Mat &img,
int borderType)
{
const int rows = dwt_util_pow2_ceil_log2(img.rows);
const int c... | TOOL | 0.888031 | 5.884012 |
fcc646b9-bba2-4ebf-bd53-f512ba910b54 | cryptoknight13/chipher-algo | Question-B/asymmetrickey_encr.cpp | #include "crypto_utils.h"
void encrypt(PublicRSAKey pubKey, std::string &plainText)
{
FILE *file = fopen("rakesh-podder.ciphertext", "w+");
int i = 0, j = 0;
char tmp[4];
int blockSize = (strlen(mpz_get_str(nullptr, 10, pubKey.n)) - 1) / 3;
int *block = (int *)calloc(blockSize + 1, sizeof(int));
char *cBl... | ALGO | 0.923514 | 5.374033 |
858f93f3-023e-4fdf-b683-a28f2ea08a8a | wangqiim/miniob-competition | deps/common/math/md5.cpp | //
// Created by Longda on 2010
//
#include "common/math/md5.h"
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
namespace common {
#define S11 7
#define S12 12
#define S13 17
#define S14 22
#define S21 5
#define S22 9
#define S23 14
#define S24 20
#define S31 4
#define S32 11
#define S33 16
#define S34 23... | ALGO | 0.982052 | 5.947883 |
78b0bdec-fbcc-46f2-925b-ce16b6538e44 | kushantgarg/Stacks | staks/infixtopostfixusingstacks.cpp | #include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct stack
{
int size;
int top;
char *arr;
};
int stackTop(struct stack* sp){
return sp->arr[sp->top];
}
int isEmpty(struct stack *ptr)
{
if (ptr->top == -1)
{
return 1;
}
else
{
return 0;
}
}
in... | ALGO | 0.999803 | 4.592377 |
c2126ea5-a7ca-4b43-87a5-0f53d3d02d0a | M0hamedIbrahim1/Problem-Solving-With-C- | random Problems/1360B - Honest Coach.cpp | //link: https://codeforces.com/problemset/problem/1360/B
//author: Mohamed Ibrahim
#include <bits/stdc++.h>
using namespace std;
int main (){
int t;
cin>>t;
while(t--){
long long size;
cin>>size;
long long arr[size],m = 1009;
for(int i = 0 ; i < size ; i++){
cin>>arr[i];
}
sort(arr,arr+size);
... | ALGO | 0.999665 | 3.707607 |
dde7557e-041c-4346-b908-2bead0980463 | Rashi-Singh1/InterviewBit-Solutions | Two Pointers/MergeArrays.cpp | //usig buffer bcs does not change space complexity (unless, we remove elements from B)
void Solution::merge(vector<int> &A, vector<int> &B) {
int as = 0, bs = 0;
vector<int> ans;
while(as < A.size() && bs < B.size()){
if(A[as] <= B[bs]) ans.push_back(A[as++]);
else ans.push_back(B[bs++]);
... | ALGO | 0.999993 | 5.004651 |
8c38010d-3df5-44e0-8bc8-acb7b2ae0a2c | raincross7/code-similarity | codes/train_code/problem107/problem107_380.cpp | // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecis... | ALGO | 0.999787 | 4.622377 |
65728dc2-ea58-4ae2-a37f-ff93e931e2b0 | umeshsakinala/Leetcode---Solutions | 1254.Number-of-Closed-Islands/1254.Number_of_Closed-Islands.cpp | class Solution {
public:
void dfs(int i, int j, vector<vector<int>>& grid) {
int m = grid.size(), n = grid[0].size();
if (i < 0 || i >= m || j < 0 || j >= n || grid[i][j] != 0)
return;
grid[i][j] = 1;
dfs(i+1, j, grid);
dfs(i-1, j, grid);
dfs(i, j+1, grid... | ALGO | 0.999986 | 6.36661 |
8f6f593f-910d-424f-bfae-e0077183a926 | Nakib-Arman/CSE318---ArtificialIntelligence | 4.DecisionTree/.history/decision_tree_20250705102420.cpp | #include<bits/stdc++.h>
using namespace std;
float getEntropy(vector<vector<string>> dataset, string attribute)
{
float entropy=0;
for (int i=0;i<dataset.size();i++){
float p = static_cast<float> (neumerator[i])/denomenator[i];
entropy -= log2(p) * p;
}
return entropy;
}
int main()
{
... | ALGO | 0.997437 | 4.359976 |
e79472f2-191c-4ee7-bd10-6e9f916945cd | Ismail-Upal/CP-Trash | Solved Problem/B_-_B.cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
int t; cin>>t;
while (t--)
{
int n;cin>>n;
int a[n];
int b[n];
for(int i=0;i<n;i++){
cin>>a[i];
b[i]=a[i];
}
sort(a,a+n);
if(n==1)cout<<"YES"<<endl;
else {
... | ALGO | 0.999973 | 3.619079 |
389386d4-c7a5-44d1-a4c5-f094e924c5e5 | kchung1995/code_test_personal | Algorithm Solving/2022/11/폰켓몬.cpp | // 문제 링크: https://programmers.co.kr/learn/courses/30/lessons/1845
#include <vector>
#include <set>
using namespace std;
int solution(vector<int> nums)
{
set<int> ponkemons;
for (auto &next : nums) {
ponkemons.insert(next);
}
if (ponkemons.size() > (nums.size() / 2)) {
return n... | ALGO | 0.999488 | 5.50238 |
d04035b3-afd1-4820-9fcd-b4b374cce3f3 | impolska742/Greedy-Codeforces | A. Omkar and Password.cpp | // Problem Link
// https://codeforces.com/problemset/problem/1392/A
// A. Omkar and Password
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
ll shortestPassword(vector<ll> &arr, ll n) {
unordered_set<ll> uset(arr.begin(), arr.end());
if (uset.size() == 1) return n;
else return 1;
}
int main... | ALGO | 0.9987 | 4.921829 |
318224b8-51af-4a1d-89bc-90b129133c79 | ayush25102001/DSA-Graphs | Graph-11(Dijkstra'sShortestPathAlgo).cpp | class Solution
{
public:
//Function to find the shortest distance of all the vertices
//from the source vertex S.
vector <int> dijkstra(int v, vector<vector<int>> adj[], int s)
{
// Code here
vector<int> distTo(v,INT_MAX);
distTo[s]=0;
priority_queue<pair<int,int>,vector<pa... | ALGO | 0.999537 | 4.978645 |
02c83bd0-35b2-41f8-9fde-d653afa44101 | Hemant989/cpp | pattern27.cpp | /*
print pattern
* * * * *
* * * * * * *
* * * * * * * * *
* * * * * * *
* * * * *
* * *
*
*/
#include<iostream>
using namespace std;
int main()
{
int row ,column, n;
cout<<"enter number :";
cin>>... | ALGO | 0.999755 | 3.667139 |
30de1327-0f04-49e1-b8cd-46544bee3a12 | Azura-yuwi/Code | MeadowV1.cpp | #include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
int n,k,w;
cin >> n >> k >> w;
int dist[n];
ll mins[n][w+1] = {INT_MAX}; //start, width
ll area[n][w+1];
for(int i = 0; i < n; i++)
{
cin >> dist[i];
mins[i][1] = dist[i];
area[i][1] = ... | ALGO | 0.999945 | 3.53783 |
da6b02ff-4dd9-4045-b583-0e2f7044bbf2 | Raaina83/C_plus_plus | c++/array/union.cpp | #include<iostream>
#include<bits/stdc++.h>
using namespace std;
vector<int> findUnion(int arr1[], int arr2[], int n, int m)
{
int i = 0;
int j = 0;
vector<int> unionArr;
while(i < n && j < m) {
if(arr1[i] <= arr2[j]) {
if(unionArr.size() == 0 || unionArr.... | ALGO | 0.999987 | 4.398533 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.