uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
26d5b0f6-fbe5-4ea5-815a-74706ce8e4bf | unclezhou486/ACM-Solutions | Mix/LOJ/535_LibreOJ_Round_6_花火.cpp | // 主席树加整体二分
#include <bits/stdc++.h>
using namespace std;
const int N=3e5+10;
int n,a[N];
struct BIT {
int n;
int b[N];
void clear(int x) {
n=x;
}
int lowbit(int x) {
return x&(-x);
}
void add(int k,int x){
for(;k<=n;k+=lowbit(k)) b[k]+=x;
}
int query(int ... | ALGO | 0.999991 | 4.011801 |
011cb423-0ba2-4283-9adb-fec41aee6370 | Thalisson-Alves/Competitive-Programming | code/graphs/check_bipartite.cpp | template <typename Graph> bool check_bipartite(const Graph &g, int u, vector<int> &color) {
assert((int)color.size() >= g.size());
color[u] = 0;
queue<int> q;
q.push(u);
while (not q.empty()) {
auto cur = q.front();
q.pop();
for (auto [x, _] : g[cur]) {
if (color[x] == color[cur]) return fa... | ALGO | 0.999525 | 6.038056 |
7190045f-3b1c-43ec-8a38-75159cde28b0 | HyperionSan/Last_One_Standing | Cactus/repos/fuka/src/Ope_eq/ope_sinh.cpp | #include "ope_eq.hpp"
#include "scalar.hpp"
#include "headcpp.hpp"
namespace Kadath {
Ope_sinh::Ope_sinh (const System_of_eqs* zesys, Ope_eq* target) : Ope_eq(zesys, target->get_dom(), 1) {
parts[0] = target ;
}
Ope_sinh::~Ope_sinh() {
}
Term_eq Ope_sinh::action() const {
Term_eq target (parts[0]->action()) ;
sw... | TOOL | 0.888172 | 5.494025 |
bb1ee978-686f-44ae-bd08-aaf64c69ccc3 | KirtiSharma0/DSA | functions/star2.cpp | #include<iostream>
using namespace std;
void star(int x){
for(int i=1;i<=x;i++){
for(int j=1;j<=i;j++){
cout<<"*";
}
cout<<endl;
}
}
int main(){
star(5);
} | ALGO | 0.999783 | 3.985697 |
9f3c1d9c-086c-4fdc-b9f2-18add0c0d8d1 | igormarkov00/Algorithms_Cpp | Queue.cpp | #include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <algorithm>
#include <set>
#include <map>
#include <cstdio>
using namespace std;
struct Node {
string color;
Node *next;
Node (string col){
color = col;
next = 0;
}
};... | ALGO | 0.965866 | 3.733126 |
f02036f4-02a0-4259-bc13-3017bfa008fc | GAURAV6871/ecommerce | coding blocks/LINKED LIST/cb218_STL2_fwlist_implementation.cpp | #include<iostream>
using namespace std;
class node
{
public:
int val;
node* next;
node(int val)
{
this->val = val;
this->next = NULL;
}
};
class forward_list
{
node* head;
int count;
public :
forward_list()
{
head = NULL;
count = 0;
}
void push_front(int val)
{... | ALGO | 0.996161 | 4.047271 |
d7d08be9-31cb-4a9b-9074-09d92ffe2115 | chret/adventOfCode | 2020/22/day22.cpp | #include <iostream>
#include <vector>
#include <string>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <functional>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <iterator>
#include <array>
using Deck_T = std::deque<int>;
using History_T = std::uno... | ALGO | 0.999506 | 4.312433 |
d2f338b3-0566-4fe3-ad91-37ca6c4c0b35 | Jackarain/avhttp | boost/libs/context/example/fiber/parser.cpp | #include <cstdio>
#include <cstdlib>
#include <exception>
#include <functional>
#include <iostream>
#include <memory>
#include <sstream>
#include <boost/context/fiber.hpp>
namespace ctx = boost::context;
/*
* grammar:
* P ---> E '\0'
* E ---> T {('+'|'-') T}
* T ---> S {('*'|'/') S}
* S ---> digit | '('... | ALGO | 0.88421 | 7.242143 |
767dfdc8-f351-48e9-aee0-4ae32935911a | Saurav-pixel/coding_practice | trianglePattern1.cpp | /*
Input: No. of rows = N (=4)
Output: *
**
***
****
*/
#include<iostream>
using namespace std;
int main(){
int n;
cout<<"Enter the no. of rows"<<endl;
cin>>n;
int i=1;
while(i<=n){
int j=1;
while(j<=i){
cout<<'*';
j++;
}
cout<<endl;
i++;
... | ALGO | 0.999893 | 4.044637 |
ba00f7de-20ab-490c-bc7b-c323752aefd3 | abdullahsadik00/DSA-CODEHELP-BY-LOVE-BABBAR | Day 2/NumericHalfPyramid.cpp | #include <iostream>
using namespace std;
int main()
{
int row = 4;
for (int i = 0; i < row; i++)
{
for (int j = 0; j <= i; j++)
{
cout << j + 1;
}
cout << endl;
}
} | ALGO | 0.998793 | 3.883068 |
b79cd9cd-fcf1-420c-a575-9acccdb96388 | bakamoridesu/Model_Predictive_Control | src/Eigen-3.3/lapack/lu.cpp | #include "common.h"
#include <Eigen/LU>
// computes an LU factorization of a general M-by-N matrix A using partial pivoting with row interchanges
EIGEN_LAPACK_FUNC(getrf,(int *m, int *n, RealScalar *pa, int *lda, int *ipiv, int *info))
{
*info = 0;
if(*m<0) *info = -1;
else if(*n<0) ... | ALGO | 0.998131 | 5.799321 |
d31da4da-e862-4fd1-a011-32b7b2f3ec1f | Kiran-Chaitu/LeetCode | 513-find-bottom-left-tree-value/find-bottom-left-tree-value.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 | 5.940329 |
d8bd74b8-3d1d-4938-91ea-7f22476de1f5 | zaqeem/c-plus-plus | diamond.cpp | #include <iostream>
using namespace std;
int main() {
int n;
cout << "Enter the number of rows (odd number): ";
cin >> n;
// Upper half of the diamond
for (int i = 1; i <= n; i += 2) {
for (int j = 0; j < (n - i) / 2; j++) {
cout << " ";
}
for (int j = 0; j < i;... | ALGO | 0.998756 | 6.645165 |
b0c24c4e-724b-4f8a-92b8-be245de4b4d4 | n0IQ/Competitive-Programming | codeforces/1178/D.cpp | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < b; i++)
#define repR(i, a, b) for (int i = a; i >= b; --i)
#define all(x) (x).begin(), (x).end()
#define rall... | ALGO | 0.99989 | 3.739359 |
9f86ed4b-cb00-40e5-9d35-322dceb8d638 | hjiang13/LLMs-in-IR | processed_data/Decompiled_Humaneval_x_cpp_164_Result_O3/CodeLlama_Humaneval_x_cpp_164/test/CPP_72.cpp | <|im_start|>system
Here is the C source code output:
```
bool will_it_fly(std::vector<int> const& v, int w)
{
if (v.size() == 0) return false;
double sum = 0;
for (int i=0; i<v.size()-1; ++i)
{
if (v[i] == v[i+1])
{
sum += v[i];
}
}
return (sum <= w);
}
```
<... | TOOL | 0.930301 | 5.971781 |
76c5e087-cda7-4a67-be90-a5cfdbb7792d | Oliwar/FIG_Bresenham_et_Quaternions | bresenham.cpp | #include "bresenham.h"
Bresenham::Bresenham(){}
Bresenham::Bresenham(int xStart, int yStart, int xEnd, int yEnd, std::vector<Pixel> &pixels){
this->xStart = xStart;
this->yStart = yStart;
this->xEnd = xEnd;
this->yEnd = yEnd;
this->xCur = xStart;
this->yCur = yStart;
int deltaX = xEnd - xS... | ALGO | 0.993365 | 4.990677 |
a4be1919-2e57-44dd-a287-621e1c89df02 | mad-99/CPP-Programs | sub_array_sum1.cpp | #include<iostream>
using namespace std;
int main()
{
int n,left=-1,right=-1;
cin>>n;
int a[100];
int maximumsum=0;
int currentsum=0;
for(int i=0;i<n;i++){
cin>>a[i];
}
for(int i=0;i<n;i++){
for(int j=i;j<n;j++){
currentsum=0;
for(int k=i;k<=j;k++){
currentsum +=a[k];
cout<<currentsum<<"\t";
... | ALGO | 0.999988 | 3.361079 |
ffe9857e-2075-47fc-b184-ac565dfa835d | nileshwankhede03/basic-cpp-programs | .history/Functions_20250218123720.cpp | #include "./stdc++.h"
using namespace std;
// pass by value
// original value nahi send karat just copy send karte and NO CHANGES IN A ORIGINAL VALUE.
void doSomething(int iNum)
{
cout << iNum << endl;
iNum += 5;
cout << iNum << endl;
iNum += 5;
cout << iNum << endl;
}
// pass by reference
// ... | ALGO | 0.990793 | 3.821743 |
60c0a5b3-8e61-46d0-af4c-db35080ecdb8 | syncfusion/SfQtWebKit | qtwebengine/src/3rdparty/chromium/third_party/skia/experimental/Intersection/TriangleUtilities.cpp | #include "TriangleUtilities.h"
// http://www.blackpawn.com/texts/pointinpoly/default.html
bool pointInTriangle(const Triangle& triangle, const _Point& pt) {
// Compute vectors
_Vector v0 = triangle[2] - triangle[0];
_Vector v1 = triangle[1] - triangle[0];
_Vector v2 = pt - triangle[0];
// Compute dot prod... | ALGO | 0.98909 | 7.570864 |
1b04cb2d-06a6-4460-8fca-4027e68fe17b | praccodes/dsl | bubble,selection,insertion,shell.cpp | // Sangam, Roll number 7247, SE Comp B
#include <bits/stdc++.h>
using namespace std;
void bubble_sort(float arr1[], int size)
{
cout<<"--------------------------------bubble sort-----------------------------------"<<endl;
float arr[size];
for(int i =0; i < size; i++)
{
... | ALGO | 0.999806 | 3.225803 |
abded237-3947-41ba-935c-f1f4ad250f4e | Anubhav299/DSA | Striver A2Z Sheet/Step 13/13.1/7_BT_postOrder.cpp | #include <bits/stdc++.h>
using namespace std;
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), left(left), right... | ALGO | 0.999958 | 5.1601 |
44ef20a3-ac6a-40ea-aced-4b3ed3236aa1 | itsharshpro/Leetcode-Solutions-Cpp | Solution_128_Longest_Consecutive_Sequence.cpp | #include<vector>
#include<iostream>
#include<algorithm>
#include<unordered_set>
using namespace std;
class Solution {
public:
int longestConsecutive(vector<int>& nums) {
int n = nums.size();
if(n==0) return 0;
int longest = 1;
unordered_set<int> st;
for(int i = 0; i<n; i++)... | ALGO | 0.999958 | 5.361457 |
6c40f4c9-4867-4e96-9017-f3383175135b | qkrsh/C_algorithm | wowrdcount.cpp | #include <stdio.h>
#define max 5
int word_count(char text[])
{
int cnt = 0;
int i = 0;
while (text[i] != '/0') {
if (text[i] == ' ') {
cnt++;
}
i++;
}
return cnt;
}
int main()
{
int count;
char test1[] = "Hello world!";
count = word_count(test1);
printf("count(%s) : % d\n", test1, count);
return ... | ALGO | 0.983623 | 3.128964 |
cd023339-87fd-4df8-871e-85d7c5f054a0 | CAgAG/Algorithms_CPP | algorithm2/12_graph/2_remove_edge2.cpp | /*************************
* @file : 2_remove_edge.cpp 并查集
* @encode : UTF-8
* @note : 冗余连接II https://leetcode.cn/problems/redundant-connection-ii/description/
* @date : 2024/4/27 20
*************************/
// 【树】就是 最少边【连通】的 图
#include "iostream"
#include "vector"
#include "algorithm"
using namespace s... | ALGO | 0.999907 | 5.70517 |
4a09c0fc-e938-4354-9c4c-dfce6bfe360f | amangupta2486/Leetcode-problems-solutions | 0100-same-tree/0100-same-tree.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.999984 | 6.366644 |
97ea780e-85c6-4a74-8c37-b77e88d23104 | GQH123/Renatus-ACM-Codes | FudanXCPC-20200815/B.cpp | #include <bits/stdc++.h>
#define rep(i, l, r) for (register int i = l; i <= r; i++)
#define per(i, r, l) for (register int i = r; i >= l; i--)
#define srep(i, l, r) for (register int i = l; i < r; i++)
#define sper(i, r, l) for (register int i = r; i > l; i--)
#define erep(i, x) for (register int i = h[x]; i; i = e[i].... | ALGO | 0.99989 | 4.006789 |
3e5d4e14-0874-4fab-bd9d-8b72922696c6 | siddhanthaldar/Algorithms-I-lab | ass9.cpp | #include <iostream>
#include <cmath>
using namespace std;
#define inf 65536
typedef struct _enode{
int vwt; // serves purpose of both vertex weight and vertex number
float ewt; //edge weight
_enode* next;
}node;
typedef node* graph;
void printgraph(graph G, int n){
cout<<"+++ The constructed graph"<<endl... | ALGO | 0.999862 | 3.912093 |
f67a94d0-c792-4a6d-a953-b8b93d83497e | rQAQ/code | PAT/PAT 1017.cpp | #include <iostream>
#include <string>
using namespace std;
int main(){
string s;
int b,tmp=0,t=0;
cin>>s>>b;
for(int i=0;i<s.length() ;i++){
t=(tmp*10+s[i]-'0')/b;
if(s.length() >1&&i==0&&t==0);
else cout<<t;
tmp=(tmp*10+s[i]-'0')%b;
}
cout<<" "<<tmp;
return 0;
}
| ALGO | 0.999566 | 3.220479 |
4d3647d7-7cb3-4159-b252-73e37e5ca091 | anuj-padmawar/hackerrank-cpp-codes1 | vector sort.cpp | #include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
/* Enter your code here. Read input from STDIN. Print output to STDOUT */
int x;
cin>>x;
vector <int> v;
int a;
for(int i=0;i<x;i++)
{
cin>>a;
v.push_back(a);
}
... | ALGO | 0.999911 | 3.842384 |
e74df904-4972-4fcf-850d-7032e96933b1 | tuc-es/UVWMonitoring | src/BooleanParetoEnumerator/main.cpp | #include <iostream>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <fstream>
#include <list>
extern "C" {
#include "picosat.h"
}
// Global variables - used in the functions called her.
char *solution = 0;
int nofVars;
PicoSAT *picosat;
void printSolution() {
std::cout << solution << "\n"... | ALGO | 0.999865 | 4.354923 |
6a05e4c5-e9c1-468a-b895-aebf2fbc9ab1 | ThienTheCreator/Programing | 1337c0d3/2181_MergeNodesInBetweenZeros.cpp | /* 2181. Merge Nodes in Between Zeros
You are given the head of a linked list, which contains a series of integers separated by 0's. The
beginning and end of the linked list will have Node.val == 0.
For every two consecutive 0's, merge all the nodes lying in between them into a single node whose
value is the sum of a... | ALGO | 0.999974 | 6.889904 |
314077e2-51dd-4418-9baa-bb92da1f7634 | paolo-torres/interview-prep | leetcode/meta/categories/trees/smallest_subtree_with_all_the_deepest_nodes.cpp | // BFS + LCA, find deepest leftmost & rightmost nodes, then find LCA
// Time: O(n)
// Space: O(n)
/**
* 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), ... | ALGO | 0.999939 | 6.934547 |
d41b63c4-7e75-4cb7-bad5-fca1469c7af3 | RohitSenta/CPP_Apna_College | Check-Pythagorian-Triplet-Or-Not-Using-Function.cpp | //Function Practice Question
//Check whether the given triplete is Pythagorian triplet or not
#include<iostream>
using namespace std;
bool check(int x, int y, int z){
int a = max(x, max(y, z));
int b, c;
if(a == x){
b = y;
c = z;
}
else if(a == y){
b = x;
c = z;
... | ALGO | 0.999258 | 4.328642 |
473cfa91-f552-4d9f-819c-ca4cc6dcd750 | Arpit06k/LeetCode | 222-count-complete-tree-nodes/count-complete-tree-nodes.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.999885 | 6.558065 |
407f6fcd-dfb0-457f-a2bb-0ec3a4c96b5b | AbrarAli-SE/Linked-List | Practice Problem/practice_8.cpp | // comparision of two linked list
#include <iostream>
using namespace std;
class Node
{
public:
int value;
Node *next;
Node(int val)
{
value = val;
next = NULL;
}
};
void insertValueAtHead(Node *&head, int val)
{
Node *newNode = new Node(val);
newNode->next = head;
head =... | ALGO | 0.999823 | 4.987209 |
11f7b15b-9449-4f2c-ae69-42ec9b783269 | shahzaib919/Basic-Programs | problem5.cpp | #include <iostream>
#include <stdlib.h>
#include <time.h>
#include <fstream>
using namespace std;
int main()
{
srand (time(NULL));
int arr[15];
bool notSorted = true;
int j = 0, tmp = 0;
for (int i = 0; i < 15; i++)
arr[i] = rand()%20;
/*Sorting using bubble sort*/
while (notSor... | ALGO | 0.995455 | 3.183521 |
97f7860b-042e-474f-8122-20658316dee3 | geroigeroi/YellowBelt | find_max_repetition_count/find_max_repetition_count/main.cpp | //
// main.cpp
// find_max_repetition_count
//
// Created by Mister on 23.11.2020.
//
#include <iostream>
#include <map>
#include <vector>
#include <set>
#include <tuple>
#include <algorithm>
enum class Lang {
DE, FR, IT
};
struct Region {
std::string std_name;
std::string parent_std_name;
std::map<Lang,... | ALGO | 0.996671 | 4.714096 |
284b999d-2543-40e8-9f67-1961140d8b29 | gavinband/bgen | 3rd_party/boost_1_55_0/libs/numeric/ublas/doc/samples/ex_triangular.cpp | #include <iostream>
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/triangular.hpp>
#include <boost/numeric/ublas/io.hpp>
using std::cout;
using std::endl;
namespace ublas = boost::numeric::ublas;
int main(int argc, char * argv[] ) {
ublas::matrix<double> M (3, 3);
for (std::size_t i=0... | TEST | 0.962238 | 4.406695 |
f3a31842-dff9-4f79-a21b-1155ef03bb0c | RIlieva02/CPPCourseEGT | LoopsAndArrays_/main.cpp | //
// main.cpp
// 04.12.23
//
// Created by Ralitsa Toneva on 4.12.23.
//
#include <iostream>
int main() {
// while and do while
//
// int counter = 1;
// while (true) {
// counter++;
// if (counter == 5){
// break;
// }
// std::cout << counter << std::endl;
//... | ALGO | 0.982833 | 3.284949 |
f6bc1f45-e762-423f-9f23-588a3aa4234d | 113bommy/deepmind_codecontests_refine | cpp_source_filter_file/cpp_train_6510_1.cpp | #include <bits/stdc++.h>
using namespace std;
map<int, int> sci;
int a[200666], b[200666];
int main(void) {
int n, i;
cin >> n;
for (i = 1; i <= n; ++i) {
int xx;
cin >> xx;
sci[xx]++;
}
int m;
cin >> m;
for (i = 1; i <= m; ++i) cin >> a[i];
for (i = 1; i <= m; ++i) cin >> b[i];
int max_re... | ALGO | 0.999882 | 3.806205 |
98c6468a-99c4-463e-802c-db43fdf3810c | Lyn-Bamboo/JPS-MPC | src/grid_path_searcher/src/Astar_searcher.cpp | #include "Astar_searcher.h"
using namespace std;
using namespace Eigen;
void AstarPathFinder::initGridMap(double _resolution, Vector3d global_xyz_l,
Vector3d global_xyz_u, int max_x_id,
int max_y_id, int max_z_id)
{
gl_xl = global_xyz_l(0); // 应该... | ALGO | 0.99902 | 3.194368 |
56e1833c-5e9b-474a-a070-d3ea0c4da4f4 | ShantanuBadmanji/DSACode | SortingAlgo/QuickSort-inplace.cpp | #include <iostream>
using namespace std;
int length = 7;
void display(int nums[], int length)
{
for (int i = 0; i < length; i++)
{
cout << nums[i] << " ";
}
cout << endl;
}
void swap(int nums[], int index1, int index2)
{
int temp = nums[index1];
nums[index1] = nums[index2];
nums[ind... | ALGO | 0.999944 | 4.535291 |
bd2845a1-ccca-487e-91eb-12b4cd499a15 | EChambiUnsa/MCC2022 | qqsort100.cpp | #include <iostream>
#include <chrono>
using namespace std;
using namespace std::chrono;
int n=0;
// Swap two elements - Utility function
void swap(int* a, int* b)
{
int t = *a;
*a = *b;
*b = t;
}
// partition the array using last element as pivot
int partition (int arr[], int low, int high)
{... | ALGO | 0.999436 | 5.17599 |
035f5a5e-a102-4965-8cee-23316c50d6a2 | josteinklogetvedt/OOP | Eksamensoppgaver/Eksamen2016Vår/windmill.cpp | #include "windmill.h"
int checkAlarm(const double value, const double threshold){
if (value > threshold && value <= MAX_WIND){return 1;}
if (value < 0.0 || value > MAX_WIND){return -1;}
return 0;
}
void printAlarm(const int id, const double wind, const int dir){
cout << "ALARM " << id << ": " << setp... | TOOL | 0.960551 | 5.512215 |
474d53d0-6413-461b-bc7d-e32ec5699c0c | okuraofvegetable/PKU | 3617.cpp | #include <cstdio>
#include <iostream>
#include <string>
using namespace std;
char s[2500],t[2500];
int l,r;
int C()
{
int sl=l,sr=r;
while(sl<sr)
{
if(s[sl]>s[sr])return 1;
else if(s[sl]<s[sr])return 0;
sl++;sr--;
}
return 0;
}
int main()
{
int n,cnt=0;
scanf("%d",&n);
for(int i=0;i<n;i++)cin >> s[i];
l=... | ALGO | 0.9998 | 3.355489 |
bd7dd28c-1184-4451-9fb2-5fa4f60e1c66 | chirags141/DataStructures | circular-queue-using-array.cpp | #include <iostream>
using namespace std;
class Queue
{
int arr[10], n = 10;
int front = -1, rear = -1;
public:
void enqueue(int data);
void dequeue();
int isEmpty();
int isFull();
int front_element();
void display();
};
int Queue ::isFull()
{
if ((rear + 1) % n == front)
{
... | ALGO | 0.990897 | 4.547272 |
a829e233-26bb-4909-ba91-c176e9a1a20f | LuuMing/HomeWork | DataStructure&Algorithm/list_reverse.cpp | #include<iostream>
using namespace std;
struct node
{
int data;
node * next;
};
node * build()
{
int N;
node * head = new node;
node* p = head;
cin >> N;
for(int i = 0; i < N;i++)
{
node * s = new node;
cin >> s->data;
p->next = s;
p = s;
}
return head;
}
void output(node * head)
{
node * p = head ->... | ALGO | 0.999951 | 4.367564 |
812be394-aa1b-4a54-b7e2-85ab40d6c4b8 | CuongDo203/DSA | xauNhiPhanKBits1.cpp | #include <bits/stdc++.h>
using namespace std;
int n, x[1001], k;
bool check(){
int cnt = 0;
for(int i = 1; i <= n; i++){
if(x[i])
cnt++;
}
return cnt == k;
}
void Dq(int i){
for(int j = 0; j <= 1; j++){
x[i] = j;
if(i == n){
if(check()){
for(int i = 1; i <= n; i++){
cout << x[i];
}
... | ALGO | 0.99991 | 4.033725 |
a2d89419-c9f5-4119-b36c-9e20678e2b49 | mejibyte/competitive_programming | Hacker Rank/Weekly Contest 35/Airports/fast.cpp | #include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <set>
#include <cassert>
#include <memory>
#include <iostream>
using namespace std;
long long oo = (long long)(1e9);
#define null NULL
struct Node {
int x, y, size;
// min = min element in this subtree
... | ALGO | 0.999965 | 4.609042 |
a061c817-0f83-4fe6-8496-1f7c76bb29f8 | shubhampawar574/Coding-Problems | June/Leetcode/13_Equal Row and Column Pairs.cpp | class Solution {
public:
int equalPairs(vector<vector<int>>& grid) {
map<vector<int>, int> hashmap;
int ans = 0;
int row = grid.size();
int col = grid[0].size();
for (int i=0; i<row; i++) {
hashmap[grid[i]]++;
}
for (int j=0; j<col; j++) {
... | ALGO | 0.999957 | 6.120719 |
9aacc4c8-3c13-4c1f-a180-2538f00d4c50 | zzz-00/OpenCV-Course | final/final.cpp | #include <opencv2/opencv.hpp>
#include <iostream>
#include <cmath>
using namespace cv;
void FlameDetection(const Mat &srcMat, Mat &dstMat);
void clear(Mat &srcMat);
void FindPoint(const Mat &srcMat, std::vector<Point> &point);
bool polynomial_curve_fit(std::vector<cv::Point> &key_point, int n, cv::Mat &A);
int main()... | TOOL | 0.939351 | 4.945395 |
47963bfd-4643-4fe0-8ffc-166451722548 | WittyXiaoKuo/C | 2024.6.20 Project1/源.cpp | //̬˳
#include<stdlib.h>
#include<assert.h>
#include<string.h>
typedef int SLDataType;
typedef struct SeqList
{
SLDataType* arr;//ָ
int size;//Чݸ
int capacity;//ռС
}SL;
//˳ĸʽ
void SLInit(SL* ps)
{
ps->arr = NULL;
ps->size = ps->capacity = 0;
}
//˳
void SLDestroy(SL* ps)
{
if (ps->arr)
{
free(ps->arr);
}
ps->a... | ALGO | 0.997074 | 3.886568 |
44baec6f-ce27-428a-8678-12153c804c09 | Sanskrita2001/Placement-Prep | 532-k-diff-pairs-in-an-array/532-k-diff-pairs-in-an-array.cpp | class Solution {
public:
int findPairs(vector<int>& nums, int k) {
set<pair<int,int>> s;
sort(nums.begin(),nums.end());
for(int i=0;i<nums.size()-1;i++){
for(int j=i+1;j<nums.size();j++){
if(abs(nums[i]-nums[j])==k)
s.insert({nums[i],nums[j]});... | ALGO | 0.999905 | 4.970583 |
25ca3a62-60e8-4c7b-9f19-4549cc1438f0 | koosaga/olympiad | ICPC/NEERC/neerc08_f.cpp | #include <bits/stdc++.h>
using namespace std;
const int MAXN = 4005;
const int mod = 1e9 + 7;
using lint = long long;
using pi = pair<lint, lint>;
lint fib[100], n;
string printFib(lint n){
string s;
for(int i=80; i; i--){
if(fib[i] <= n){
n -= fib[i];
s.push_back('1');
}
else if(s.size()) s.push_back('... | ALGO | 0.999984 | 4.036783 |
2fef134b-79c8-4ab9-8983-4e55448a589d | akshatvermavi/shl_assessment_recommendation | venv/Lib/site-packages/sklearn/utils/src/MurmurHash3.cpp | // Note - The x86 and x64 versions do _not_ produce the same results, as the
// algorithms are optimized for their respective platforms. You can still
// compile and run any of them on any platform, but your performance with the
// non-native version will be less than optimal.
#include "MurmurHash3.h"
//-------------... | ALGO | 0.9982 | 7.198757 |
0e5dd5c0-bd39-4205-b17e-7fd42327bf76 | KrishanKantAgnihotri/CP-Solutions | CodeChef/C++14/DREDIV/42221154.cpp |
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
#define ll long long
#define ii pair<int,int>
#define vii vector<ii>
#define vi vector<int>
#define vl vector<ll>
#define mii map<int,int>
#define uii unordered_map<int,int>
#define all(x) x.begin(),x.end()
#define ff first
#defin... | ALGO | 0.999929 | 3.804285 |
e7464c3b-28f0-4adc-9672-da9b79441e68 | blackbeardONE/CheggHero | coursehero_auto_reg/account_registered_on_20180326/txtsource/try.cpp | #include <iostream>
#include <cstring>
using namespace std;
char L[100001];
int a,b,c;
int A[100001],B[100001],C[100001];
int s;
int r1,r2;
int p1,p2;
bool e0,ok1,ok2;
int i;
void copiere(int X[],int &dim)
{
for(int i=1; i<=a; i++)
X[i]=A[i];
dim=a;
}
int cautaultim(int X[],int dim, int rest)
{
int ... | ALGO | 0.99997 | 3.405836 |
58efc8d4-84cb-4548-be1e-dbb187522ab8 | raincross7/code-similarity | codes/train_code/problem320/problem320_125.cpp | #include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<ve... | ALGO | 0.999957 | 3.431534 |
c64deccc-322c-4f66-bb2f-9e78c41a0898 | masashi545/Cpp | abc208/b/main.cpp | #include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
int fact(int n) {
if (n == 1) {
return 1;
}
return n * fact(n - 1);
}
int main() {
int P;
cin >> P;
int ans = 0;
for (int i = 10; i >= 1; --i) {
int x = fact... | ALGO | 0.999688 | 4.436599 |
3c5d5ad3-69f0-4c24-b4fe-e44077f71ed9 | zhaoyang10/ACM_HDU | hdu_4289_Control.cpp | #include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cst... | ALGO | 0.999777 | 3.865225 |
c3a5bd11-9671-4acc-8896-887788e4f35a | Solaiman20/Muqin | Frontend/code/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.997371 | 6.76073 |
cd5b7063-534f-4219-b7bf-665eefea8b0a | berkeley-pie/android_frameworks_base | core/jni/android_net_NetUtils.cpp | #define LOG_TAG "NetUtils"
#include "jni.h"
#include <nativehelper/JNIHelp.h>
#include "NetdClient.h"
#include <utils/misc.h>
#include <android_runtime/AndroidRuntime.h>
#include <utils/Log.h>
#include <arpa/inet.h>
#include <net/if.h>
#include <linux/filter.h>
#include <linux/if_arp.h>
#include <netinet/ether.h>
#inc... | TOOL | 0.902905 | 7.009649 |
02b9ac5f-1745-4884-a409-a8fefc7188a7 | gxbbct/LeetCodeDaily | 1439/1439.cpp | #include <iostream>
#include <vector>
#include <cstring>
#include <algorithm>
using namespace std;
class Solution {
public:
int kthSmallest(vector<vector<int>>& mat, int k) {
int pre[k];
int cur[mat[0].size() * k];
memset(pre, 0, sizeof(pre));
int size = 1;
for (auto& row : ... | ALGO | 0.999962 | 4.892794 |
2f568c30-086a-4f2e-ac2b-038b240f2930 | runlnr/solid-octo-sniffle | CSES/CSES - Restaurant Customers.cpp | #include <bits/stdc++.h>
#define ss second
#define ff first
#define endl "\n"
#define sp ' '
#define pback push_back
using namespace std;
typedef long long ll; typedef string str;
const int MOD = 1e9+7, N = 1e5+7, J = 1e3+7;
//chetmeorroiroiorr
map<ll, ll> mp;
void solve(int n) {
int a, b;
ll ans = 0, temp =... | ALGO | 0.999688 | 4.182399 |
15556172-edf2-482b-94d0-fa8c82df91de | sujitchandra/Leetcode | 0485-max-consecutive-ones/0485-max-consecutive-ones.cpp | class Solution {
public:
int findMaxConsecutiveOnes(vector<int>& nums) {
int n = nums.size();
int count = 0;
int maximum = 0;
for (int i=0; i<n; i++){
if(nums[i] != 1)
count = 0;
else
count++;
maximum = max (maximum ,... | ALGO | 0.999937 | 6.036642 |
a00ec8e0-d74b-4077-bbed-0d4c0a6d9070 | TheCloudlet/leetcode-in-cpp | sliding-window/003-longest-substring-without-repeating-characters/first-try.cpp | class Solution {
public:
int lengthOfLongestSubstring(string s) {
int max_len = 0;
int l = 0, r = 0;
std::unordered_set<char> ss; // substring set
while (r < s.size()) {
if (ss.find(s[r]) != ss.end()) {
ss.erase(s[l]);
l++;
} else {
ss.insert(s[r]);
max_len... | ALGO | 0.999261 | 6.430223 |
7583c953-afa8-40cd-8fd9-ae886c3bc339 | akshay4/Android_framework_av_Jellybean | media/libstagefright/codecs/mp3dec/src/pvmp3_poly_phase_synthesis.cpp | /*
------------------------------------------------------------------------------
PacketVideo Corp.
MP3 Decoder Library
Filename: pvmp3_poly_phase_synthesis.cpp
Date: 09/21/2007
------------------------------------------------------------------------------
REVISION HISTORY
Description:
-----------... | ALGO | 0.999154 | 4.507547 |
8607a4e8-7fbe-4592-817d-318deaad5abb | AvaRavVikSinghania/dynamicProgramming | longestdivisiblesubset.cpp | #include<bits/stdc++.h>
using namespace std;
vector<int> lengthsubsequence(vector<int>&arr){
int n=arr.size();
sort(arr.begin(),arr.end());
vector<int>dp(n,-1),hash(n);
int maxi=1;
int lastindex=0;
for(int i=1;i<n;i++){
hash[i]=i;
for(int prev=0;prev<i;prev++){
if(arr... | ALGO | 0.999989 | 3.828676 |
b9106176-6f82-443f-8fc2-8d252d5ba593 | Saurav4742/DSA-Practice | Link List/Detect_Loop.cpp | // Detect loop or cycle in a linked list
// Given a linked list, check if the linked list has a loop (cycle) or not. The below diagram shows a linked list with a loop.
// Detect loop in a linked list using Floyd’s Cycle-Finding Algorithm:
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
// #define in... | ALGO | 0.999701 | 5.665718 |
947f3e9b-1eed-4407-b760-199bd5c15d0c | rashedcs/LAB | Numerical Analysis/09.cpp | #include<bits/stdc++.h>
using namespace std;
double newton(double x[], double y[], int n, double f)
{
double h=x[1]-x[0];
double s=1;
double p=(f-x[1])/h;
double sum=y[0];
for(int i=1; i<=n-1; i++)
{
fo... | ALGO | 0.999832 | 4.303242 |
1f5e8ee9-4b0d-47cb-a47c-307d7193b647 | RoofMi/baekjoon_ljb | 프로그래머스/2/42888. 오픈채팅방/오픈채팅방.cpp | #include <string>
#include <vector>
#include <unordered_map>
#include <sstream>
using namespace std;
vector<string> split(string str, char del) {
vector<string> strTemp;
stringstream ss(str);
string temp;
while (getline(ss, temp, del)) {
strTemp.push_back(temp);
}
return strT... | ALGO | 0.997406 | 5.24761 |
ef65845e-3b44-4283-b313-d6ab6cece610 | KrishKumar3004/Contests | Mar5(College Contest)/A_MONSTER_AND_SHOOTING_GAME.cpp | #include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define mod 1000000007
void solve()
{
ll n, res = 0;
cin >> n;
vector<ll> a(n), ans(n, 0);
for (ll i = 0; i < n; i++)
{
cin >> a[i];
}
for (ll i = n - 2; i >= 0; i--)
{
// cout << a[i + 1] << endl;
... | ALGO | 0.999837 | 4.273897 |
300a5ec5-7bb2-4d2c-bd48-96613a6f5dc5 | georgehodgkins/Zhuque_artifact | clobber-pmdk/llvm/libcxx/test/std/numerics/numeric.ops/transform.inclusive.scan/transform_inclusive_scan_bop_uop.pass.cpp | // <numeric>
// UNSUPPORTED: c++98, c++03, c++11, c++14
// template<class InputIterator, class OutputIterator, class T,
// class BinaryOperation, class UnaryOperation>
// OutputIterator transform_inclusive_scan(InputIterator first, InputIterator last,
// OutputItera... | TEST | 0.973298 | 7.27215 |
018644a4-7d7c-460d-841c-7a5e377b9b8b | sj963samyak/DSA-codes | Stack/RedundantBrackets.cpp | //two redundant conditions are there
// 1.if immediate pop does not encounter any bracket then we can say redundant brackets are there for ex.((a))
// 2.(((a+B))+c) in this when we pop untill down then the opening bracket is left which is pop condition
stack<char>st;
for(auto& ch:s){
if(ch==')'){
... | ALGO | 0.997728 | 3.126809 |
111b3e3c-4d69-420e-ac6a-62ecbed20055 | atharv-asr-group/cses_solvings | cses_roundtrip2.cpp | #include<iostream>
#include<vector>
#include<queue>
#include<functional>
#include<cstring>
#include<array>
#include<set>
#include<algorithm>
#include<map>
#define ll long long
using namespace std;
#define ar array
const int mxN=1e5;
int n,m,p[mxN];
vector<int> adj[mxN];
bool vis[mxN], act[mxN];
void dfs(int u){
vi... | ALGO | 0.999972 | 3.993031 |
851e8d01-1772-4ef8-9b6e-55108608658d | BotPhil01/ChessBot | src/board.cpp | #include "../include/types.hpp"
#include "../include/constants.hpp"
#include "../include/bitboard.hpp"
#include "../include/board.hpp"
#include "../include/sliding.hpp"
#include "../include/rands.hpp"
#include <cctype>
#include <functional>
#include <memory>
#include <string>
#include <cassert>
// fen consists of
// p... | TOOL | 0.865674 | 4.112205 |
e853af70-9c34-4b4d-a1bc-aac6cc7a35f6 | wx-chevalier/algorithm-examples | 剑指 Offer/cpp/65_AddTwoNumbers/AddTwoNumbers.cpp | //==================================================================
// ָOfferԹپͱ⡷
// ߣκ
//==================================================================
// 65üӼ˳ӷ
// Ŀдһ֮ͣҪںڲʹã
// š
#include <cstdio>
int Add(int num1, int num2)
{
int sum, carry;
do
{
sum = num1 ^ num2;
carry = (num1 ... | ALGO | 0.99962 | 4.316279 |
73ec6eb0-e2f2-4891-bfa6-a8a36f6144a0 | imkhateeb/Problem-Solving | Contests/codeforces/RANDOM/Ed_87_Div2_B.cpp | #include <bits/stdc++.h>
#define let long long
#define MOD 1000000007
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define endl "\n"
#define vi vector<let>
#define vvi vector<vector<let>>
#define vs vector<string>
#define vpii vector... | ALGO | 0.999918 | 4.343973 |
672e024b-6aa3-45a3-9c0d-2e33a97199c4 | Singh-Amarjot/learnYard_DSA | fundamental practice problems/arrays/interchange diagonal elements.cpp | #include <iostream>
using namespace std;
int main() {
int matrix[5][5];
int temp;
for(int i=0;i<5;i++){
for (int j =0;j<5 ;j++ ) {
cin>>matrix[i][j];
}
}
for(int i=0;i<5;i++){
for (int j =0;j<5 ;j++ ) {
cout<<matrix[i][j]<<' ';
... | ALGO | 0.999969 | 3.091983 |
bebfe8d8-0f33-4afd-a59a-a5e9bb082811 | sugiyem/LeetCode | medium/Rotate Image/Solution.cpp | class Solution {
public:
void rotate(vector<vector<int>>& matrix) {
int n = matrix.size() - 1;
for (int i = 0; i <= n / 2; i++) {
for (int j = 0; j < n - 2 * i; j++) {
swap(matrix[i][i + j], matrix[i + j][n - i]);
swap(matrix[i][i + j], matrix[n - i][n - i... | ALGO | 0.999992 | 6.461722 |
0d4eec15-0c1d-455f-b00f-c62fd8c52aac | kpgng/interview-prep | leetcode/linkedin/all/find_median_from_data_stream.cpp | /*
Implement data structure that gets the median from a data stream
Max heap of lower values & min heap of higher values, access to mids
Time: O(log n) + O(1)
Space: O(n)
*/
class MedianFinder {
public:
MedianFinder() {
}
void addNum(int num) {
if (lower.empty()) {
... | ALGO | 0.999985 | 6.249115 |
ef5be364-13ef-4cde-a64f-1c4354acbde9 | LucidaLu/template | code/2_Mathematics/7_FastFourierTransform.cpp | const int N=1<<22;
const double PI=acos(-1);
struct X {
double x,y;
X operator +(X const &z) const { return {x + z.x, y + z.y}; }
X operator -(X const &z) const { return {x - z.x, y - z.y}; }
X operator *(X const &z) const { return {x * z.x - y * z.y, x * z.y + y * z.x}; }
}w[N];
void FFT(X a[],int n... | ALGO | 0.998311 | 3.521456 |
30f49a4b-193d-4ac6-809f-2e0ff2b1980a | Milez213/CityTrial | frustum/frustummain.cpp | /* ------------------------------------------------------
View Frustum Culling - Lighthouse3D
-----------------------------------------------------*/
#include <GL/glut.h>
#include "Vec3.h"
#include "FrustumG.h"
#include <stdio.h>
float a = 0;
float nearP = 1.0f, farP = 100.0f;
float angle = 45, ratio=1;
int ... | TOOL | 0.969774 | 5.632989 |
f8d6fe6a-b2c1-480f-bb1b-3393321fd69b | 192121089/c--day3 | first n perfect nos..cpp | #include <iostream>
#include <math.h>
using namespace std;
int isPerfect(long long int n) {
long long int dsum = 0;
long long int i;
for (i = 1; i <= sqrt(n); ++i) {
if (n % i == 0) {
if (i == n / i) {
dsum += i;
}
else {
dsum += i;
dsum += n / i;
}
}
}
dsum = dsum - n;
if (dsum ... | ALGO | 0.999888 | 4.063462 |
997bbd5d-35ec-463b-9659-d0b61d8f6e5b | talha-10xE/LLVM-Profiler | libcxx/test/std/algorithms/alg.sorting/alg.binary.search/lower.bound/ranges.lower_bound.pass.cpp | // UNSUPPORTED: c++03, c++11, c++14, c++17
// template<forward_iterator I, sentinel_for<I> S, class T, class Proj = identity,
// indirect_strict_weak_order<const T*, projected<I, Proj>> Comp = ranges::less>
// constexpr I ranges::lower_bound(I first, S last, const T& value, Comp comp = {},
// ... | TEST | 0.958016 | 7.40536 |
fd55140b-3ec3-4985-86e6-9c17f275f4ff | ML4SE2022/group3 | data/walkccc-1666132586/C++/751 IP to CIDR.cpp | class Solution {
public:
vector<string> ipToCIDR(string ip, int n) {
vector<string> ans;
long num = getNum(ip);
while (n > 0) {
const long lowbit = num & -num;
const long count = lowbit == 0 ? maxLow(n) : firstFit(lowbit, n);
ans.push_back(getCIDR(num, getPrefix(count)));
n -= co... | ALGO | 0.999554 | 6.151893 |
83fc47b7-5039-46e7-a247-81065c7cda36 | anandakevin/vault-competitive-programming | Online Judges/Hackkerrank/Interview 1 Week Prep Kit/Day 3/caesar_chiper.cpp | #include <bits/stdc++.h>
#include <cctype>
using namespace std;
string ltrim(const string &);
string rtrim(const string &);
/*
* Complete the 'caesarCipher' function below.
*
* The function is expected to return a STRING.
* The function accepts following parameters:
* 1. STRING s
* 2. INTEGER k
*/
string c... | ALGO | 0.99992 | 5.914509 |
2f0624f1-e744-4838-86fe-332fb9e3513c | jovinlidan/competitive-programming | CodeForces/GNU C++17/1165B | Polycarp Training/70765262.cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
int n, needK = 1;
cin >> n;
int arr[200005] = {};
for(int i = 0; i < n; i++)
{
cin >> arr[i];
}
sort(arr, arr+n);
for(int i = 0; i < n; i++)
{
if( arr[i] >= needK)
{
//cout << arr[i] <<"-" << needK << endl;
needK++;
}
}
cout << ne... | ALGO | 0.999881 | 3.612649 |
3af731d3-70fa-4a18-a3a6-b70e37c4d2d1 | NguyenDucThuan-11226156/code_c | Pointer/functionpointer.cpp | #include<stdio.h>
#include<stdlib.h>
void printfhelloworld()
{
printf("Hello World\n");
}
int *Add(int* a, int* b)
{ int*c =(int*)malloc(sizeof(int));
*c= (*a)+(*b);
return c;
}
int main()
{
int a=2,b=4;
int *ptr= Add(&a,&b);
// printfhelloworld();
printf("Sum=%d\n",*ptr);
}... | TOOL | 0.874811 | 3.401529 |
77a6650d-70ef-4321-ad2c-e865b0dec652 | kundangupta04/Basic | c++/ch12_sortingAlgorithm/q4.cpp | /**
* Given two sorted arrays, Write a program to merge them in a
* sorted Manner.
*/
#include<iostream>
#include<vector>
using namespace std;
void merge(int arr1[], int n1, int arr2[], int n2, int arr3[]){
int a=0; //array1
int b=0; //array2
int c=0; //array3
while(a<n1 and b<n2){
if(arr1[... | ALGO | 0.999965 | 4.755286 |
fb0713b0-44e2-4709-ac61-2910ec065b96 | Aokman12/LeetCode | 0509-fibonacci-number/0509-fibonacci-number.cpp | class Solution {
public:
int solve(int n,vector<int> &dp){
if(n<=1){
return n;
}
if(dp[n] != -1){
return dp[n];
}
dp[n] = solve(n-1,dp) + solve(n-2,dp);
return dp[n];
}
int fib(int n) {
vector<int> dp(n+1,... | ALGO | 0.999999 | 6.147393 |
9a376725-7696-48f3-b100-a00e678bc650 | nasimstg/leetcode-all | cpp/0300-longest-increasing-subsequence.cpp | /*
Given int array, return length of longest increasing subsequence
Ex. nums = [10,9,2,5,3,7,101,18] -> 4, [2,3,7,101]
Why DP? 1) Max/min of smth, 2) make decisions based on prev decisions
"Decision": is it worth it to consider this number?
If use may contribute to better LIS, but may also eliminat... | ALGO | 0.99998 | 6.646259 |
f3ac8a38-22d9-44b4-a0eb-89d871f81073 | ronniegnr/hacking | src/bd/com/ronnie/hacking/uri_online_judge/beginner/1043-Triangle.cpp | #include<iostream>
#include<algorithm>
#include<stdio.h>
using namespace std;
int main() {
float arr[3];
for(int i=0; i<3; i++) {
cin >> arr[i];
}
float perimetro = arr[0] + arr[1] + arr[2];
float area = (arr[0]+arr[1]) * arr[2] * .5;
sort(arr, arr+3);
if(arr[0]+arr[1] >... | ALGO | 0.988383 | 3.934602 |
f7adc71c-f987-46d3-a9ee-a34a87a8dbae | ZQ-XPY/cpp | foundation/process/semaphore.cpp | /*
**********************************************************
* Author : M_Kepler
* EMail : <EMAIL>
* Last modified: 2018-12-21 14:24:51
* Filename : semaphore.cpp
* Description : 进程同步与互斥(信号量)
* 保护共享资源, 确保资源在一个时刻只有一个进程独享
* (多进程中全局变量起不到作用是否可通过信号量来完成?)
**********************************... | ALGO | 0.998082 | 4.668862 |
b241d4b7-4b48-4ce9-a8d1-31ac2749f67f | henryhoangduong/Algorithm-Collection | Hash/index.cpp | #include <iostream>
#include <vector>
#include <list>
using namespace std;
class MyHashSet {
private:
// Vector of linked lists (buckets)
vector<list<int> > buckets;
// Hash set size (number of buckets)
int size;
// Hash function to map key to an index
int hash(int key) {
return key %... | ALGO | 0.9982 | 6.066715 |
d68ecc72-21b3-4caf-a344-7c3e99a0de30 | hymsly/CompetitiveProgramming | codechef/CLRL.cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> up,down;
bool ok(){
for(int i=1;i<up.size();i++){
if(up[i] >= up[i-1]) return false;
}
for(int i=1;i<down.size();i++){
if(down[i] <= down[i-1]) return false;
}
return true;
}
int main(){
//ios_base::sync_with_stdio(0);
int t;ci... | ALGO | 0.999973 | 4.038898 |
66ed1909-2083-4759-83d3-bb5d0bbdb92d | EnriqueOrtiz2020630629/Algoritmos2021B | CoeficientesBinomiales/main.cpp | #include <stdio.h>
#include <iostream>
#include <vector>
using namespace std;
vector<vector<int>> dp(100, vector<int>(100,0));
int bruta(int i, int n){ // T(n) <= 2T(n-1) + 1
if(i == 0 or i == n) //O(2^n)
return 1;
else{
return bruta(i-1,n-1) + bruta(i,n);
}
}
int dinamic(int i, int n){
... | ALGO | 0.999968 | 4.420671 |
513dee7b-2818-4e9f-aeb6-0abcc23e867b | runarer/advent-of-code | 2019/10/aoc2019_10_1.cpp | #include <string>
#include <vector>
#include <iostream>
#include <fstream>
#include <map>
#include <charconv>
/*
*
*
1. Generer grunnkoordinatene.
1a. X og Y m vre delig p samme heltall.
1b. Hvis X eller Y er et primtall s m det andre tallet vre delig p det. som (9,3) => (3,1)
1c.
2.... | ALGO | 0.997951 | 5.432261 |
8a741357-85bb-4ecb-9293-d279e2557865 | Satori27/MAI | 2/trash/c++/olympiad/icpc/main1.cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
string a, b;
cout << "? 0" << endl;
cin >> a >> b;
if (b == "main") {
int n;
int l = 0, r = 4 * 9;
int m;
while (true) {
m = (l + r) / 2;
... | ALGO | 0.999627 | 3.07427 |
85c83766-5590-40f0-b6c3-325ffb03d658 | Just-A-Pixel/DSA_Bank | Tree/Maximum_path_sum.cpp | int maxpathsum(Node *root, bool isanytaken)
{
if(root==NULL && isanytaken==false)
return INT_MIN;
if(root==NULL)
return 0;
if(isanytaken==false)
{
int op1 = root->data + maxpathsum(root->left,true);
int op2 = root->data + maxpathsum(root->right,true);
int op3 = ro... | ALGO | 0.999892 | 5.641546 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.