uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
84a91a78-5cb2-44f5-89f8-d82634ae73ca | gongbaochicken/Coding-Practice | C++ Solutions/Dynamic_Programming/LC053_MaximumSubarray.cpp | /*Leetcode: Maximum Subarray
Find the contiguous subarray within an array (containing at
least one number) which has the largest sum.
For example, given the array [−2,1,−3,4,−1,2,1,−5,4],
the contiguous subarray [4,−1,2,1] has the largest sum = 6.
*/
Solution: Dynamic Programming(C++)
class Solution {
public:
... | ALGO | 0.999988 | 6.502807 |
9993ba07-3218-4f75-85bc-64b71c5fdc77 | janm31415/eigen-3.4.0 | doc/examples/matrixfree_cg.cpp | #include <iostream>
#include <Eigen/Core>
#include <Eigen/Dense>
#include <Eigen/IterativeLinearSolvers>
#include <unsupported/Eigen/IterativeSolvers>
class MatrixReplacement;
using Eigen::SparseMatrix;
namespace Eigen {
namespace internal {
// MatrixReplacement looks-like a SparseMatrix, so let's inherits its trai... | ALGO | 0.999175 | 6.112806 |
d409ee81-9f46-4ee2-b91f-a2ce66cebbbf | Nihta/learn-cpp | Codesignal/Intro/Other/digitsProduct.cpp | /*
Cho một số nguyên product: 0 ≤ product ≤ 600
Tìm sô nguyên dương nhỏ nhất (lớn hơn 0) mà tích các chữ số bằng với product
Không tìm được return -1
*/
#include <iostream>
using namespace std;
int digitsProduct(int product) {
if (product < 10)
return product == 0 ? 10 : product;
string result = "";... | ALGO | 0.99937 | 4.951242 |
e62db375-c540-49bf-abf3-fad631acbd80 | pranith7867/Coding | coding_minutes_Essentials/1_Arrays/Array_template.cpp | #include<bits/stdc++.h>
using namespace std;
void solve(int arr[], int n)
{
}
void display(int arr[],int n)
{
cout<<"output of the array is"<<endl;
for(int i=0;i<n;i++)
{
cout<<arr[i]<<" ";
}
}
int main()
{
int t;
cin>>t;
while(t--)
{
i... | ALGO | 0.998288 | 3.080615 |
c918fecf-0328-43be-8f8a-d788ecbb142d | kohyatoh/contests | aoj/2411/2411.cpp | #include <stdio.h>
#include <string.h>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long Int;
#define NUM (120000)
#define DAY (4000000)
int N, Q, t[NUM], x[NUM], y[NUM];
Int w[NUM];
int s[NUM];
Int val[NUM];
vector<int> ev[DAY];
Int a, b,... | ALGO | 0.999743 | 3.55284 |
fe1a3c1a-e6c4-4b9a-916f-896a3a45ed30 | eryueniaobp/leetcode | revised/Validate Binary Search Tree.cpp | /**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
* O(n) 遍历一遍
*/
// Solution 1 : the most direct way .using iterative way to solve it
public class Solution {
/**
* @param ... | ALGO | 0.999995 | 5.600169 |
4a6ca748-9522-4a47-a01a-3a8997d82abc | KMORaza/Data_Structures | Graphs/Clique_Enumeration.cpp | #include <iostream>
#include <vector>
#include <set>
class CliqueEnumerationAlgorithm {
public:
CliqueEnumerationAlgorithm(int numVertices);
void addEdge(int v, int w);
void enumerateCliques();
private:
int numVertices;
std::vector<std::vector<int>> adjacencyList;
void bronKerbosch(std::set<int>... | ALGO | 0.9999 | 5.933223 |
9d2c1193-d40c-4703-b5d0-7010a2c01a49 | juruoO-o/CPP_LC | LC232.cpp | #include <bits/stdc++.h>
using namespace std;
struct ListNode {
int val;
ListNode *next;
ListNode() : val(0), next(nullptr) {}
ListNode(int x) : val(x), next(nullptr) {}
ListNode(int x, ListNode *next) : val(x), next(next) {}
};
struct TreeNode {
int val;
TreeNode *left;
TreeNode *... | ALGO | 0.999711 | 5.087728 |
65c999d3-174b-4111-b7f0-deff9123c099 | Subham-102/100-Days-of-Coding-Challenge | Day9.cpp | // Brute Force:
// 1.Merge Both Array
// 2.Sort them
// 3.Find Median
// TIME COMPLEXITY: O(n)+O(nlogn)+O(n)
// SPACE COMPLEXITY: O(1)
class Solution {
public:
double findMedianSortedArrays(vector<int>& nums1, vector<int>& nums2) {
// Initia... | ALGO | 0.999995 | 6.530922 |
50bc83cf-cbe5-4a31-b162-ebe8e0efb987 | dprCZD/cpp-algorithm | 287_find_duplicate.cpp | #include "common.h"
class Solution {
public:
int findDuplicate(vector<int>& nums) {
int n = nums.size();
int left = 0;
int right = n - 1;
int ans = -1;
while (left <= right) {
int mid = (left + right) >> 1;
int cnt = 0;
for (int i = 0; i <... | ALGO | 0.999908 | 5.873191 |
30c57f4f-68a4-4426-aa6d-99289b6f6348 | PAMCH/Coding_Magic_Iron | OOJ_2024/OOJ_2024/OOJ_2024.cpp | #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cmath>
#include <climits>
int main()
{
int n, i, j, temp, dir = 0;
int s[1001], d[1001], c[1001];
scanf("%d", &n);
for (i = 1; i <= n - 1; i++) {
scanf("%d %d %d", &s[i], &d[i], &c[i]);
}
for (i = 1; i <= n - 2; i++) {
... | ALGO | 0.999971 | 4.154254 |
834b4ed3-375a-4605-9e54-b6f926599f5e | kamilszymczak1/my_solutions | cf/contests/1670/c.cpp | #include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <bitset>
#include <map>
#include <queue>
using namespace std;
struct DSU {
vector<int>f;
int n, components;
DSU(int _n) {
f.resize(_n);
n = _n;
components = n;
for(int i = 0; i < n; i++)
... | ALGO | 0.999953 | 3.903485 |
d2783254-4cf4-4552-85ef-47f3ecbefb36 | srikanthmaram/Datastructures-and-Algorithms | LinkedList/C++/linkedlist.cpp | #include<iostream>
using namespace std;
class node{
public:
int data;
node *link;
node(int d)
{
data=d;
link=NULL;
}
};
void insertAtHead(node* &head,int d)
{
node *temp=new node(d);
temp->link=head;
head=temp;
}
void insertAtTail(node* &head,int d)
{
node *tempnod... | ALGO | 0.999849 | 4.031677 |
c5e39c07-4db9-455e-b1ce-9c9585f47d04 | JJH-Log/BaekjoonOnlineJudgeSolvedList | 202104/4M2W/B4195.cpp | #include <iostream>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <utility> //pair 사용
#include <algorithm> //reverse 사용
#include <math.h> // sqrt 사용
#include <set>
using namespace std;
map<string, pair<string, int>> m;
string findRoot(string me) {
if (m[me].second) {
return me;
}
... | ALGO | 0.999943 | 4.134589 |
b79e0ff0-1844-44a7-92e1-8377386b7d7c | JiHaoChina/Algorithm_Study | Home Work/第五周/Leetcode 1011_在D天内送达包裹的能力.cpp | class Solution {
public:
int shipWithinDays(vector<int>& weights, int days) {
//找到一个K,然后按照K进行是否可行的判断
//左边界而言,由于我们不能「拆分」一个包裹,因此船的运载能力不能小于所有包裹中最重的那个的重量,
//即左边界为数组 \textit{weights}weights 中元素的最大值。
int left = *max_element(weights.begin(), weights.end()) ;
//右边界而言,船的运载能力也不会大于所有包裹的重量之和,即右边界为数组 \t... | ALGO | 0.999985 | 5.795279 |
aea2030a-0b2a-41ac-b403-a77087e240d5 | akhilkammila/leetcode | random-questions/hard/ways-to-form-target-string.cpp | #include <vector>
#include <string>
#include <iostream>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__)
#include </Users/akhilkammila/Competitive Programming/debug.h>
#else
#define DEBUG(...) 47;
#endif
const ll MODULO =... | ALGO | 0.999992 | 5.264093 |
5e828e2f-0319-436d-8dbd-78cce8806aec | sanhaa/Coding | ps/SWExpert/S_1260(화학물질2).cpp | // S 1260 화학물질2
#include <iostream>
using namespace std;
#define MAX_M 25 // 최대 행렬 개수
#define MAX_N 110 // 입력 이차원 배열의 가로 세로
#define INF 987654321
const char sharp = '#';
int mmin(int a, int b) { return a < b ? a : b; }
int main() {
int tc = 0; cin >> tc;
for (int t = 1; t <= tc; t++) {
int N = 0; cin >> N; /... | ALGO | 0.999831 | 3.653743 |
98a6f944-ec9d-4e99-bca6-f8cf4a39f4de | LinLorry/DataStructuresExperiment | res/LinkList/Term_LinkList.cpp | //
// Created by lorry on 11/29/18.
//
#include <random>
#include "Term_LinkList.h"
#include "../Models/Term.h"
void displayCurrentObject(MyLinkList<Term> & termLinkList)
{
cout << "\t\t";
MyLinkList<Term>::NodePointer pointer = termLinkList.getHead();
while(pointer)
{
cout << pointer->data;
... | ALGO | 0.996634 | 3.456353 |
95174ef9-72a5-4de3-bbf3-2cce9f6797c0 | Bitdash-org/BITDASH.github.io | Bitdash/src/scrypt.cpp | #include "scrypt.h"
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <openssl/sha.h>
static inline uint32_t be32dec(const void *pp)
{
const uint8_t *p = (uint8_t const *)pp;
return ((uint32_t)(p[3]) + ((uint32_t)(p[2]) << 8) +
((uint32_t)(p[1]) << 16) + ((uint32_t)(p[0]) << 24));
}
static i... | ALGO | 0.986104 | 5.341605 |
1b195073-3b7c-4919-a93b-8597ab141cdb | hzfsls/leetcode-supercrawl | data/2379.minimum-recolors-to-get-k-consecutive-black-blocks/code_snippets/sol.cpp | class Solution {
public:
int minimumRecolors(string blocks, int k) {
}
}; | ALGO | 0.99896 | 5.203636 |
43cf5a3a-805d-455d-ac7d-6bb8b412a630 | mathalro/competitive-programming | Codeforces/DIV2/Contests/Educational33/b.cpp | #include <bits/stdc++.h>
using namespace std;
bool beaut (int n) {
string aux = bitset<64>(n).to_string();
string s;
bool foo = false;
int i = 0;
while (aux[i] == '0') i++;
while (i < aux.size()) s += aux[i++];
int n1 = s.size()/2+1;
int n0 = s.size()/2;
i = 0;
int cont = 0;
while (s[i] == '1' && i < ... | ALGO | 0.999987 | 4.905286 |
75fb9ced-a112-4c1b-b765-0945872e2adb | dingty-zz/peloton | src/postgres/backend/regex/regc_nfa.cpp | #define NISERR() VISERR(nfa->v)
#define NERR(e) VERR(nfa->v, (e))
/*
* newnfa - set up an NFA
*/
static struct nfa * /* the NFA, or NULL */
newnfa(struct vars * v,
struct colormap * cm,
struct nfa * parent) /* NULL if primary NFA */
{
struct nfa *nfa;
nfa = (struct nfa *) MALLOC(sizeof(struct nfa));
... | ALGO | 0.988833 | 4.130187 |
b4663cb8-e626-43a3-9585-5e6f89bf9526 | Mneach/Leetcode-Solution | 0853-car-fleet/0853-car-fleet.cpp | class Solution {
public:
int carFleet(int target, vector<int>& position, vector<int>& speed) {
vector<pair<int,int>> bucket;
int answer = 0;
for(int i = 0; i < position.size(); i++){
bucket.push_back(make_pair(position[i], speed[i]));
}
... | ALGO | 0.999649 | 5.74306 |
efcd33ed-95b1-4f36-8fa0-e19a1470b1cd | SergeyKrivtsov/OOP-repository | OOP/Alikhanian Kyrylo (OOP)/Абстрактні класи (10 прака гугл класс).cpp | #include <iostream>
#include <vector>
#include <cmath>
#include <stdexcept>
using namespace std;
class Figure {
public:
virtual double area() const = 0;
virtual double perimeter() const = 0;
virtual ~Figure() = default; // Віртуальний деструктор для коректного видалення похідних об'єктів
};
class Rectang... | TOOL | 0.958727 | 6.272485 |
63f5dda3-44c9-4653-8cde-dfd46309f3e3 | zeyongj/LeetCode | 1227-number-of-equivalent-domino-pairs/1227-number-of-equivalent-domino-pairs.cpp | class Solution {
public:
struct hash_pair {
size_t operator()(const pair<int,int>& p) const {
return p.first * 31 + p.second;
}
};
int numEquivDominoPairs(vector<vector<int>>& dominoes) {
unordered_map<pair<int,int>, int, hash_pair> mp... | ALGO | 0.999941 | 6.647666 |
d5ae5542-80de-4f92-88d4-5242e0863e78 | Iwaide/AtCoder | abc399/a/main.cpp | #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { ... | ALGO | 0.999948 | 4.050977 |
339c9e6f-7d85-40c6-a2c7-e4e65f24c127 | rachit0045/LEARNING-DSA | FUNCTION IN C++/areaOfCircle.cpp | #include <iostream>
using namespace std;
float areaofcircle(float radius)
{
float area = 3.14 * (radius * radius);
return area;
}
int main()
{
float radius;
cout << "enter the radius :";
cin >> radius;
float area = areaofcircle(radius);
cout << "Area of circle is " << area << endl;
retur... | ALGO | 0.997722 | 3.263355 |
d8d6fcb3-c8a1-49fd-af35-4f01b7e083ba | RomanBapst/PX4_mavros | fw_att_controller/include/fw_att_controller/eigen/doc/examples/Tutorial_ArrayClass_accessors.cpp | #include <Eigen/Dense>
#include <iostream>
using namespace Eigen;
using namespace std;
int main()
{
ArrayXXf m(2,2);
// assign some values coefficient by coefficient
m(0,0) = 1.0; m(0,1) = 2.0;
m(1,0) = 3.0; m(1,1) = m(0,1) + m(1,0);
// print values to standard output
cout << m << endl << endl;
... | ALGO | 0.983688 | 3.536336 |
466c7032-f24c-48d4-bc33-ea078aab1069 | Medix1075/Online_Judge_Project_Django | Auth/codes/fc4eed3b-e82c-46ee-9cb6-f81893359598.cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
int n,m,k;
cin>> n>>m>>k;
vector<vector<char>> paths(n, vector<char> (m));
for(int i=0; i<n; i++){
for(int j=0; j<m; j++){
cin>>paths[i][j];
}
}
vector<vector<vector<pair<int,int>>>> adj(n, vector<vector<pair<int,int>>>(m));... | ALGO | 0.999979 | 3.505869 |
42bb2b6a-65e9-460a-ba22-13165e94cf58 | Sachin-Bharadwaj/CarND-MPC | src/Eigen-3.3/unsupported/doc/examples/MatrixExponential.cpp | #include <unsupported/Eigen/MatrixFunctions>
#include <iostream>
using namespace Eigen;
int main()
{
const double pi = std::acos(-1.0);
MatrixXd A(3,3);
A << 0, -pi/4, 0,
pi/4, 0, 0,
0, 0, 0;
std::cout << "The matrix A is:\n" << A << "\n\n";
std::cout << "The matrix exponential ... | ALGO | 0.999651 | 3.706936 |
bc060bcc-6a21-4743-a721-5f6cec4c2476 | sarvex/leetcode-java | solution/2100-2199/2181.Merge Nodes in Between Zeros/Solution.cpp | /**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(int x, ListNode *next) : val(x), next(next) {}
* };
*/
class Solution {
public:
ListNode* mergeNodes(... | ALGO | 0.99998 | 5.319037 |
95922c2e-3b1f-4c07-a1e2-be4b90812792 | mahbobhasan/course-3 | Tree/tree_from_inorder_and_preorder_traversal.cpp | #include <bits/stdc++.h>
using namespace std;
class treenode{
public:
int data;
treenode* leftchild;
treenode* rightchild;
treenode(int val){
data=val;
leftchild=NULL;
rightchild=NULL;
}
};
void printtree(treenode* root, int level );
void inorder(treenode*root, string& chk);
void ... | ALGO | 0.999979 | 3.962975 |
49638266-9e70-4f23-8ac1-e1697c653892 | konigsberg/annotated-folly | folly/detail/RangeSse42.cpp | #include <folly/detail/RangeSse42.h>
#include <cassert>
#include <folly/Portability.h>
// Essentially, two versions of this file: one with an SSE42 implementation
// and one with a fallback implementation. We determine which version to use by
// testing for the presence of the required headers.
//
// TODO: Maybe... | ALGO | 0.884946 | 6.512613 |
fdab7299-db95-45d5-82fc-0a32da75897e | Morphinity/Codeforces | div2/153/1.1.cpp | #include<iostream>
#include<limits.h>
#include<algorithm>
using namespace std;
int main(){
int n;
cin >> n;
int arr[n];
for(int i=0; i<n; i++)
cin >> arr[i];
int ans = 0;
int tmp;
for(int i=0; i<n; i++){
tmp = arr[i];
ans = max(ans,tmp);
for(int j=i+1; j<n;j++){
tmp ^= arr[j];
... | ALGO | 0.999978 | 4.265987 |
29092a7d-1ee2-47b0-891e-5cb3a67519b6 | abhijeetSinghRajput/Daily-LeetCoding-Challenge | october/OCT_12_Find_in_Mountain_Array.cpp | /**
* // This is the MountainArray's API interface.
* // You should not implement it, or speculate about its implementation
* class MountainArray {
* public:
* int get(int index);
* int length();
* };
*/
class Solution {
int findPeak(MountainArray &mountainArr){
int left = 0;
int right = ... | ALGO | 0.999977 | 6.22604 |
2908b209-213e-4a19-9991-04be2c86872a | Afifhasan2003/all_code | C++/beginner/numbers/max.cpp | #include<iostream>
using namespace std;
int main() {
int a,b,c;cin>>a>>b>>c;
int maxofab=(a+b+abs(a-b))/2;
int max= (c+maxofab + abs(c-maxofab))/2;
cout<<max<<endl;
return 0;
} | ALGO | 0.999931 | 3.600703 |
0bf540e9-d336-4bbc-b30a-f77b433c0637 | ob22a/Leetcode | 2836-neither-minimum-nor-maximum/neither-minimum-nor-maximum_1.cpp | class Solution {
public:
int findNonMinOrMax(vector<int>& nums) {
if(nums.size()<3) return -1;
sort(nums.begin(),nums.end());
return nums[1];
}
};
| ALGO | 0.999967 | 4.969687 |
821c8fa8-f210-412f-92c2-28156ffc3fd8 | professorDeveloper/Cpp-Daily-Tasks | examTutorial2/task1.cpp | //
// Created by azamov on 10/1/2024.
//
#include <iostream>
using namespace std;
#include <cmath>
int main() {
int n;
cout << "Enter n:";
cin >> n;
if (n % 2 == 0) {
cout << sqrt(n) << endl;
} else {
cout << pow(n, 2) << endl;
}
}
| ALGO | 0.993537 | 5.472587 |
e2f5105e-9753-420f-b38e-1ed9b7863405 | Vandyshge/2sem | lab4/D.cpp | #include <iostream>
using std::cin;
using std::cout;
using std::endl;
int* now_get_me_some_bytes(unsigned int n);
void now_free_some_bytes(int* p);
int main() {
unsigned int n;
cin >> n;
int *a = now_get_me_some_bytes(n);
for (int i = 0; i < n; i++)
cin >> a[i];
int s = 0;
for (int i = 0; ... | ALGO | 0.999625 | 3.662756 |
b5cb8814-e2eb-40ad-8f21-8d7c6d436b54 | harshleet/leetsolution | 718-maximum-length-of-repeated-subarray/maximum-length-of-repeated-subarray.cpp | class Solution {
public:
int ans=0;
int helper(int ind1,int ind2,vector<int>& nums1,vector<int>& nums2,vector<vector<int>>&dp,int cnt){
if(ind1>=nums1.size() || ind2>=nums2.size()){
return 0;
}
if(dp[ind1][ind2]!=-1){
return dp[ind1][ind2];
}
int ntake=max(helper(ind1+1,ind2,nums1,nu... | ALGO | 0.999992 | 6.05526 |
b8fc1736-3897-4fc0-a04e-fca9e2dba0d0 | laliluielo/programming_problems | Easy/Trojke/trojke.cpp | //Trojke https://open.kattis.com/problems/trojke
#include <iostream>
#include <string>
#include <vector>
using std::string;
using std::cin;
using std::cout;
class N_N_Matrix
{
public:
N_N_Matrix(size_t rows);
int& operator()(size_t i, size_t j);
int operator()(size_t i, size_t j) const;
int countColum... | ALGO | 0.999729 | 3.797908 |
5200f314-085f-4aca-a925-b625d9f2b779 | PLayL04/ParallelProg | Prog1.cpp | #include <iostream>
#include <vector>
#include <pthread.h>
const int TOTAL_STUDENTS = 10000;
int total_knowers = 0;
struct FacultyData {
std::vector<int> groups;
int knowers;
};
void* calculateKnowers(void* arg) {
FacultyData* data = (FacultyData*)arg;
data->knowers = 0;
for (int knowers_in_group... | ALGO | 0.997006 | 5.505795 |
9ee80e06-0873-4d6e-9823-cdd24a246b7a | ATHARVA-GAWAS/GFG_DeutscheBank-Challenge | Day08/solution.cpp | //{ Driver Code Starts
// Initial template for C++
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
// User function template for C++
class Solution {
public:
int getMinDiff(vector<int> &arr, int k) {
int n=arr.size();
sort(arr.begin(), arr.end());
int maxi... | ALGO | 0.999892 | 5.640279 |
b6461ac3-dc14-410f-ae80-48a557a7703a | ishandutta2007/codeforces | hongzy/normal/235/E.cpp | #include <algorithm>
#include <cstdio>
using namespace std;
const int m = (1 << 30) - 1;
const int N = 4e6 + 5;
int p[N], mu[N], f[N], c;
bool tag[N];
void sieve(int n) {
mu[1] = 1;
for(int i = 2; i <= n; i ++) {
if(!tag[i]) { p[++ c] = i; mu[i] = -1; }
for(int j = 1; j <= c && i * p[j] <= n; j ++) {
tag[i * p... | ALGO | 0.999883 | 4.234929 |
07186b50-469d-4b12-9b7c-647b85c5235e | gkeksd/studyCPP | 챕터4/챕터4_Lab1.cpp | #include <print>
#include <iostream>
using namespace std;
int main() {
int sco1, sco2, sco3;
int sum;
int min, max;
double avg;
print("ù ° л Էϼ: ");
cin >> sco1;
print(" ° л Էϼ : ");
cin >> sco2;
print(" ° л Էϼ: ");
cin >> sco3;
min = sco1;
max = sco1;
if (sco2 < min) {
min = sco2;
}
if (sco3 < ... | ALGO | 0.965613 | 3.537814 |
b60b545f-fb9f-47ce-b474-8a55dcc02cb9 | AnuranjN/CPP-Practice | HackerRank/ConditionalStatement.cpp | #include <bits/stdc++.h>
using namespace std;
string ltrim(const string &);
string rtrim(const string &);
int main()
{
string n_temp;
getline(cin, n_temp);
int n = stoi(ltrim(rtrim(n_temp)));
// Write your code here
if (n==1)
cout<<"one";
else if(n==2)
cout<<... | ALGO | 0.999206 | 4.678886 |
287225ae-0e0a-4a5b-98b5-2c959f4722af | wgoni/BOJ | BOJ/sources/1/0000/10989.cpp | #include <iostream>
#include <cstring>
using namespace std;
int main() {
int DAT[10001], N;
cin.tie(0), ios::sync_with_stdio(0);
memset(DAT, 0, sizeof(DAT));
cin >> N;
for (int n = 0; n < N; n++) {
int tmp;
cin >> tmp;
DAT[tmp]++;
}
int cnt = 0;
for (int i = 0; ; i++) {
if (DAT[i]) {
for (int j = 0... | ALGO | 0.999734 | 3.757734 |
0a7921f7-31ac-41e4-a4cc-9c455c481582 | Jesus2481/OOP-1 | Source.cpp | #include <iostream>
#include <cmath>
#include <stdexcept>
class Integer {
public:
//
Integer() : Integer(false, 0u) {}
Integer(bool sign, unsigned units) : sign_(sign), units_(units) {}
Integer(int number) {
if (number < 0) {
sign_ = true;
units_ = ::abs(number);
... | ALGO | 0.992038 | 6.595682 |
7670f85e-af3f-42b2-ac93-f281f3ba6e6a | ishandutta2007/codeforces | ilith/normal/1696/B.cpp | #include<bits/stdc++.h>
#define FOR(i,a,b) for(int i=a;i<=b;++i)
#define ROF(i,b,a) for(int i=a;i>=b;--i)
using namespace std;
const int N=1e5+7;
int T,n,z,a[N],ans;
void solve(){
scanf("%d",&n),ans=0;
int cnt=0;
FOR(i,1,n){
scanf("%d",a+i),a[i]=!!a[i];
if(a[i]==1&&a[i-1]==0)++cnt;
}
printf("%d\n",min(cnt,2));... | ALGO | 0.999764 | 4.669837 |
7103943c-be4b-4abd-a7ec-ba5f9baaca5e | etnk125/POSN-second-camp | FINAL/03.cpp | #include<iostream>
using namespace std;
main()
{
int n,index=0;
cin>>n;
for(int i=1;i<n;i++)
{
int j=i;
int temp=j;
while(j>0)
{
temp+=j%10;
j/=10;
}
if(temp==n)
{
index =i;
break;
}
}
if(index==0)cout<<0;
else cout<<index;
}
| ALGO | 0.999802 | 3.368877 |
d1f4f90a-ff39-43c9-87b6-34d668abb4f5 | Little-grow/LeetCode | JS/1823-Find-the-Winner-of-the-Circular-Game.cpp | class Solution {
public:
int findTheWinner(int n, int k) {
int winner = 0;
for (int i = 1; i <= n; ++i) {
winner = (winner + k) % i;
}
return winner + 1; // Convert back to 1-indexed
}
};
| ALGO | 0.999993 | 6.412598 |
1d310636-8214-4d0c-9e3e-2561b176f5f7 | cymbl/llvm-project | llvm/lib/Transforms/Utils/FixIrreducible.cpp | #include "llvm/ADT/SCCIterator.h"
#include "llvm/Analysis/LoopIterator.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Transforms/Utils.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#define DEBUG_TYPE "fix-irreducible"
using namespace llvm;
namespace {
struct FixIrreducible : publ... | ALGO | 0.998122 | 7.83103 |
6a8aeccb-3f3e-4133-b143-8b11748f372d | PashaEagle/my-competitive-programming | leetcode/April_Coding_Challenge/1046_LastStoneWeight.cpp | // Sun, 12th April, 2020
class Solution {
public:
int lastStoneWeight(vector<int>& stones) {
while(stones.size() > 1){
sort(stones.begin(), stones.end());
int diff = stones[stones.size() - 1] - stones[stones.size() - 2];
stones.pop_back();
if (diff ==... | ALGO | 0.999964 | 5.601305 |
c30039ff-0e1c-4248-8169-47e4a449b0bc | vSzemkel/CppStuff | usaco/chapter1/sprime.cpp | /*
ID: marcin.8
LANG: C++
TASK: sprime
PROBLEM STATEMENT: https://train.usaco.org/usacoprob2?a=czIYf0BMp0z&S=sprime
*/
#include <fstream>
#include <vector>
std::ifstream task_in("sprime.in");
std::ofstream task_out("sprime.out");
static int is_prime(const int64_t n) {
if (n <= 3) return true;
if (n % 2 == 0 ... | ALGO | 0.999734 | 5.090053 |
5cdb5450-71eb-4380-8c1f-c720bb1b47bd | sbakic/algorithms | hackerearth/practice/basic-programming/bit-manipulation/monk's-choice-of-numbers/main.cpp | #include <bits/stdc++.h>
using namespace std;
int make(int n) {
int ans = 0;
while (n) {
n &= (n - 1);
ans++;
}
return ans;
}
int main() {
int t;
cin >> t;
while (t--) {
int n, k, a[1000], sum = 0;
cin >> n >> k;
for (int i = 0; i < n; i++) {
cin >> a[i];
a[i] = make(a[i... | ALGO | 0.999834 | 4.084893 |
3d0f3d59-1ef1-46bc-83e4-ef999a72c396 | lishuwei0424/xmind_for_cs_basics | 10.刷题经验/C++_剑指Offer分类练习/source-二叉树/LayerPrintTree.cpp | #include "stdio.h"
#include <queue>
#include <iostream>
using namespace std;
typedef struct BiTNode
{
char data; /*结点的数据域*/
struct BiTNode *lchild , *rchild; /*指向左孩子和右孩子*/
} BiTNode , *BiTree;
/*创建一棵二叉树*/
void CreatBiTree(BiTree *T)
{
char c;
scanf("%c",&c);
if(c == ' ') *T = NULL;
else{
... | ALGO | 0.999962 | 3.384101 |
caacdd68-561e-4fde-b8ef-eba027d3909c | bhavaygoel/Data-Structures-and-Algorithms | 1056-capacity-to-ship-packages-within-d-days/1056-capacity-to-ship-packages-within-d-days.cpp | class Solution {
public:
bool isValid(vector<int>& weights, int days, int maxi){
int day = 1, sum =0;
for(int i=0; i<weights.size(); i++){
sum += weights[i];
if(sum > maxi){
day++;
sum = weights[i];
}
if(day > days) retu... | ALGO | 0.999997 | 5.671072 |
0c9f3b89-d74d-402e-9bda-29e6e79d9727 | sirAdarsh/CP-files | PRACTICE/subordinates.cpp | /*----- || Hare Krishna || -----*/
/* "WHY DO WE FALL, BRUCE?" */
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define elif else if
#define pb push_back
#define pf push_front
#define PI 3.1415926535897932384
#define MOD 10000000... | ALGO | 0.999885 | 3.560007 |
21fa4c07-4aaf-4a1f-80f8-80f1e7ed6c45 | Kato1337/Data-Structures-Algorithms | Grocery Inventory Simulation.cpp | #include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
int main() {
vector<string> currentInventory = {"apples", "bananas", "oranges", "pears"};
vector<string> shipment = {"kiwis", "bananas", "grapes"};
vector<string> soldOutItems = {"apples", "oranges"};
c... | TOOL | 0.998514 | 5.486065 |
728b6356-c238-4713-b387-1d8f06401b09 | Shahraaz/CP_P_S5 | ICPC_Mirrors/Nitc_9.0/nwerc2019all/gnollhypothesis/submissions/wrong_answer/monte_carlo.cpp | #include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (auto i=(a); i<(b); ++i)
#define iter(it,c) for (auto it = (c).begin(); it != (c).end(); ++it)
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
const int INF = 2147483647;
int ma... | ALGO | 0.999897 | 3.109649 |
c1400532-ea84-45f2-9ae9-f4c6d576fbde | nnatchy/Algorithm-Design | grader/greedy/ex04e2_fknapsack.cpp | #include<iostream>
#include<vector>
#include<algorithm>
#include<limits.h>
#include<iomanip>
#define ll long double
#define IO ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define rep(a, b) for(int i = a; i < b; i++)
#define pll pair<ll, ll>
#define ppl pair<ll, pll>
using namespace std;
int main() {
IO;
... | ALGO | 0.999958 | 4.014775 |
72b8089b-145f-4ccf-8cf2-481254f1a487 | cvzoya/memorability-distinctiveness | toolboxes/@kde/mex/entropyGradISE.cpp | #include <math.h>
#include "mex.h"
#define MEX
#include "cpp/BallTreeDensity.h"
double erf(double c) { // disabled for lack of windows erf f'n
return 1.0;
}
const double pi = 3.141592653589;
const double s2pi = .398942280401432; // = 1/sqrt(2*pi);
const double s2 = 1.414213562373095; // = sqrt(2);
void e... | ALGO | 0.999785 | 4.285758 |
01c625c4-105d-44f5-8f8e-647b8939c1b4 | ishandutta2007/codeforces | leapfrog/normal/613/D.cpp | //
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline void read(T &x)
{
x=0;char c=getchar(),f=0;
for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=1;
for(;c>='0'&&c<='9';c=getchar()) x=(x<<1)+(x<<3)+(c^48);
if(f) x=-x;
}
struct EDGE
{
int et,head[100005];struct edge{int to,nxt;}e[200005];
inline v... | ALGO | 0.999845 | 4.141771 |
4d933502-5d26-4b59-869d-f61c66d98b9f | krnbatra/SPOJ-Solutions | SGIFT.cpp | /*Let's get high :D*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007LL
#define EPS 1e-9
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define M_PI 3.14159265358979323846
template <typename T> T gc... | ALGO | 0.999961 | 4.309023 |
f5d75f70-b05a-441c-81c8-f71cec9cd2d4 | soolabettu/cp | code_forces/683/a.cpp | /* https://cses.fi/problemset/task/1633 */
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vs = vector<string>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using pi = pair<int, int>;
using pl = pair<ll, ll>;
using vpi = vector<pair<int, int>>;
using vpl = vector<pai... | ALGO | 0.996845 | 3.086128 |
50a3ec0f-d32d-454f-80c7-c366770a8d54 | ishandutta2007/codeforces | sunset/normal/913/B.cpp | #include <bits/stdc++.h>
using namespace std;
#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)
typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;
template <typ... | ALGO | 0.999997 | 3.800728 |
59e9d860-4c6b-4f4a-abbb-39bf10a10b87 | Shraddha-Kotwar/DSAL_ASSIGNMNENT | prims.cpp | #include<iostream>
#include<cstring>
using namespace std;
int main()
{
int n,visit[10],min,cost[10][10],s,ne=1,u,v,total=0;
cout<<"\nEnter the no of nodes: ";
cin>>n;
for(int i=1;i<=n;i++)
{
visit[i]=0;
}
cout<<"\nWeighted Graph : ";
for(int i=1;i<=n;i++)
{
for(int j=1;j<=n;j++)
{
cout<<"\nWeight... | ALGO | 0.999453 | 3.197079 |
49d19704-91ce-4236-99bc-a7e71328705f | ishandutta2007/codeforces | pyqe/normal/1037/C.cpp | #include <bits/stdc++.h>
using namespace std;
long long n;
bitset<1000069> a[2],vtd;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
long long i,ii,z=0;
string s;
cin>>n;
for(ii=0;ii<2;ii++)
{
cin>>s;
for(i=1;i<=n;i++)
{
a[ii][i]=s[i-1]-'0';
}
}
for(i=1;i<=n;i++)
{
if(a[... | ALGO | 0.999973 | 3.718413 |
8d601857-1847-40d1-81e2-fc696c2b76de | kostyadev/hacker_rank | CircularArrRot/CircularArrRot/CircularArrRot.cpp | #include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
#include <memory>
#include <functional>
using namespace std;
string ltrim(const string &);
string rtrim(const string &);
vector<string> split(const string &);
vector<int> circularArrayRotation(const vector<int>& a, const... | ALGO | 0.99982 | 4.200041 |
5f222aed-1471-40e9-959c-262eca6603f5 | Sudhanshu2306/Competitive-coding | Double_Rent.cpp | #include <bits/stdc++.h>
using namespace std;
// Commonly used loops
#define for0(i, n) for (int i = 0; i < (n); ++i)
#define for1(i, n) for (int i = 1; i <= (n); ++i)
#define rfor0(i, n) for (int i = (n) - 1; i >= 0; --i)
#define rfor1(i, n) for (int i = (n); i >= 1; --i)
// Minimum and maximum macros
#define min3(a... | ALGO | 0.999222 | 4.349816 |
48fc71b5-336d-48d4-a365-07a8bb41696d | Salvist/computer-vision | CPP/median_filter.cpp | #include <iostream>
#include <fstream>
#include <string>
using namespace std;
class Reader {
public:
int numRows{ -1 }, numCols{ -1 }, minVal{ -1 }, maxVal{ -1 };
int maskRows{ -1 }, maskCols{ -1 }, maskMin{ -1 }, maskMax{ -1 };
int newMin{ -1 }, newMax{ -1 };
int thrVal{ -1 };
int** body;
int** mirrorFramed... | ALGO | 0.990382 | 4.358547 |
0d7e7ed9-47ce-48a3-a4f0-c0886218152f | zjambor/Elte2020beadando1 | 2020_beadando1/2020_beadando1.cpp | #include <iostream>
#include <fstream>
#include <future>
#include <thread>
#include <vector>
#include <sstream>
#include <string>
#include <tuple>
#include <array>
using namespace std;
typedef std::vector<std::tuple<int, int>> vec;
//typedef std::vector<vec> matrix;
typedef std::tuple<int, int>** matrix;
void kiir(s... | ALGO | 0.999923 | 4.606866 |
e09ba624-47d3-4154-b61f-63621b62ec83 | sneharameshjadhav-22/DSA | LinkedList/max consecutive sequence in binary array(of 0 and 1).cpp | /*Given a binary array nums, return the maximum number of consecutive 1's in the array.
Example 1:
Input: nums = [1,1,0,1,1,1]
Output: 3
Explanation: The first two digits or the last three digits are consecutive 1s. The maximum number of consecutive 1s is 3.
Example 2:
Input: nums = [1,0,1,1,0,1]
Output: 2*/
class Sol... | ALGO | 0.999983 | 6.303087 |
af79f553-af1b-4dd1-951c-5e847aea0818 | artsrjeong/31166 | Developing/HoistwayPlanner/HoistwayPlanGen.cpp | #include "stdafx.h"
#include <math.h>
#include <crtdbg.h>
#include "HoistwayPlanGen.h"
#include "HoistwayPlannerDefs.h"
#include "HoistwayPlanSelection.h"
#define EXTERN extern
#include "HoistwaySchedule.h"
#include "HoistwayPlanner.h"
#undef EXTERN
#include "..\COGS\2DSIM_DEFS.H"
#ifdef WITH_DEBUG
#include <time.h>
e... | ALGO | 0.999298 | 3.054866 |
6bae642e-9982-4b97-a291-84742f10de17 | yuliy/sport_programming | codeforces/118/A/main.cpp | #include <stdio.h>
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <list>
#include <algorithm>
using namespace std;
int main() {
char buf[128];
scanf("%s", buf);
for (char *c = buf; *c; ++c) {
if (strchr("AOYEUIaoyeui", *c))
... | ALGO | 0.996738 | 3.828402 |
b17da841-292f-4f5c-94f8-494698c17915 | jiangbr/eigen | bench/bench_norm.cpp | #include <typeinfo>
#include <iostream>
#include <Eigen/Core>
#include "BenchTimer.h"
using namespace Eigen;
using namespace std;
template <typename T>
EIGEN_DONT_INLINE typename T::Scalar sqsumNorm(T& v) {
return v.norm();
}
template <typename T>
EIGEN_DONT_INLINE typename T::Scalar stableNorm(T& v) {
return v.s... | TEST | 0.989033 | 6.645317 |
c6efebf8-e01b-457a-a9ea-9acae580b92a | FarukIb/My-Competitve-Programming-Solutions | CSES/school_dance/main.cpp | #include <bits/stdc++.h>
#define mp make_pair
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
struct edge {
int f, t, cap, flo;
edge() {flo = 0;}
edge(int f, int t, int cap) : f(f), t(t), cap(cap) {
flo = 0;
}
};
struct Dinitz {
in... | ALGO | 0.999931 | 3.63098 |
ce073027-8251-4b5a-8306-a0cf01f1e156 | nadimmorol890/XPSC | Week 14/Day 5/C_Boring_Day.cpp | #include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
ios::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while (t--) {
ll n, l, r;
cin >> n >> l >> r;
vector<ll> a(n);
for (ll i = 0; i < n; i++) {
cin >> a[i];
... | ALGO | 0.999835 | 4.031012 |
4a5f3a1a-350b-4fce-894a-052d71b7de00 | sanjanprakash/Hackerrank | Algorithms/Sorting/runningtimeofalgorithms.cpp | #include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include <iostream>
using namespace std;
int insertionSort(int size, int ar []) {
int temp, i, j, count = 0;
for (i = 1; i < size; i++) {
for (j = i; j > 0; j--) {
if (ar [j] < ar [j... | ALGO | 0.999836 | 3.947122 |
e7cd9121-3fbd-43fe-b683-827f973d6cd0 | NusantaraSoftware/TumeriQ | libs/Box2D/Dynamics/b2Island.cpp | #include <Box2D/Collision/b2Distance.h>
#include <Box2D/Dynamics/b2Island.h>
#include <Box2D/Dynamics/b2Body.h>
#include <Box2D/Dynamics/b2Fixture.h>
#include <Box2D/Dynamics/b2World.h>
#include <Box2D/Dynamics/Contacts/b2Contact.h>
#include <Box2D/Dynamics/Contacts/b2ContactSolver.h>
#include <Box2D/Dynamics/Joints/b2... | ALGO | 0.999955 | 7.188112 |
3f0a4b14-5a53-48a5-87b1-7b0684724ce4 | Hansimov/cpp-primer | ch01/1-12 for sum.cpp | #include <iostream>
int main() {
int sum=0;
for (int i=-100; i<=100; ++i) {
sum+=i;
}
std::cout << sum << std::endl;
return -1;
} | ALGO | 0.98808 | 3.978453 |
57a3f2c2-d213-4c32-9dcf-f0d259f408c4 | mastermanas805/codelibrary | Tree/Kth largest element in BST/code.cpp | // https://practice.geeksforgeeks.org/problems/kth-largest-element-in-bst
class Solution
{
public:
int ans = -1;
void find(Node *root, int& K)
{
if(root == NULL) return;
find(root->right, K);
K--;
if(K == 0) ans = root->data;
find(root->left, K);
}
... | ALGO | 0.999936 | 4.796615 |
3a073d36-bb61-4536-9f06-96100e58d0cd | StevenL2017/Codeforces | problem/archive/2121/2121F.cpp | #include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <cstring>
#include <string>
#include <array>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <algorithm>
#include <functional>
using namesp... | ALGO | 0.998477 | 4.180017 |
6a922515-8102-4af9-afd2-590dbd068ed6 | ankit-tiwari-dev/DSA-Problem-Set-II | Stack_arrays.cpp | #include <iostream>
using namespace std;
struct stack
{
int size;
int top;
int *arr;
};
int isEmpty(struct stack *ptr)
{
if (ptr->top == -1)
{
return 1;
}
else
return 0;
}
int isFull(struct stack *ptr)
{
if (ptr->top == ptr->size - 1)
{
return 1;
}
e... | ALGO | 0.957343 | 3.522907 |
684d75b9-4ba8-40bc-bbf9-2aca4d7c4150 | jorgenglenndal/CMB | src/PowerSpectrum.cpp | #include"PowerSpectrum.h"
//====================================================
// Constructors
//====================================================
PowerSpectrum::PowerSpectrum(
BackgroundCosmology *cosmo,
RecombinationHistory *rec,
Perturbations *pert,
double A_s,
double n_s,
double kpi... | ALGO | 0.998607 | 5.304462 |
c3ba3cfa-c58a-4547-a19f-4a47a9a7429d | Competicoes-de-Algoritmos-UFRJ/Problemas-Resolvidos | Treinamento Calouros/2024/Turma 2/Contests/1 - Loops, Arrays e Vector/g.cpp | #include <bits/stdc++.h>
using namespace std;
#define endl '\n'
int main(){
ios_base::sync_with_stdio(false), cin.tie(nullptr);
int t;
cin >> t;
while(t--){
int n;
cin >> n;
vector<int> v(n), freq(n+1);
for(int i=0; i<n; i++){
cin >> v[i];
... | ALGO | 0.99997 | 4.251494 |
79cf1c29-afe5-4c46-98ed-e838aa94e9fa | linouk23/leetcode | 77.cpp | // 77. Combinations - https://leetcode.com/problems/combinations
#include "bits/stdc++.h"
using namespace std;
class Solution {
private:
vector<vector<int> > result;
int n_, k_;
void helper(vector<int> comb, deque<bool> used, int last_used_num) {
if ((int)comb.size() == k_) {
result.e... | ALGO | 0.999915 | 5.894157 |
e87f995f-2deb-497f-b96b-31ec59b77e3a | DionysiosB/CodeChef | REACHFAST.cpp | #include<cstdio>
int main(){
long t; scanf("%ld", &t);
while(t--){
long x, y, k; scanf("%ld %ld %ld", &x, &y, &k);
long d = x - y; if(d < 0){d = -d;}
printf("%ld\n", (d + k - 1) / k);
}
}
| ALGO | 0.999748 | 3.601769 |
6c95ddd7-bfa0-430a-bc40-668f7a67046a | EmptyDust/Algorithm-Codes-and-writeups | codes/-0x30_competition/-0x33_codeforces/919/B.cpp | #include <bits/stdc++.h>
#define int long long
using namespace std;
constexpr int MAXN = 6e6;
int nums[MAXN];
void solve() {
int n, k, x;cin >> n >> k >> x;
int sum = 0;
for (int i = 0;i < n;++i)cin >> nums[i], sum += nums[i];
sort(nums, nums + n);reverse(nums, nums + n);
int i = 0;
for (;i < ... | ALGO | 0.999946 | 4.807837 |
60f0f6a7-bd1e-4d28-ae76-895f2c47e012 | ankursinghbisht/DSA_CheatSheet | C++/Stacks & Queues/07_reversing_string_using_stack.cpp | /*
Idea:
pushing all characters to stack and popping and inserting in string, will reverse it
*/
//{ Driver Code Starts
#include<bits/stdc++.h>
using namespace std;
char* reverse(char* str, int len);
int main()
{
long long int t;
cin >> t;
while (t--)
{
char str[10000];
cin >> str;
... | ALGO | 0.999851 | 5.489424 |
3c51e27b-e16b-4a13-b39b-f3bd30239a09 | vedanty3/dsa-codeground | leetcode-gfg-solutions/gfg-solutions/Kth smallest element.cpp | // https : // practice.geeksforgeeks.org/problems/kth-smallest-element5635/0/#
class Solution
{
public:
// arr : given array
// l : starting index of the array i.e 0
// r : ending index of the array i.e size-1
// k : find kth smallest element and return using this function
int kthSmallest(int arr[]... | ALGO | 0.999978 | 5.293655 |
b9e33004-3b15-400d-a48e-397a60ac4eb3 | keijak/comp-pub | atcoder/abc221/C/main.cpp | #include <bits/stdc++.h>
#define REP_(i, a_, b_, a, b, ...) \
for (int i = (a), END_##i = (b); i < END_##i; ++i)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define ALL(x) std::begin(x), std::end(x)
using i64 = long long;
template<typename T, typename U>
inline bool chmax(T &a, U b) {
ret... | ALGO | 0.999981 | 4.79816 |
9e7e0e1d-090a-4269-b575-dcdd04c31f9a | sumitsojha88/leetcode-solutions | Sort/Medium/75. Sort Colors.cpp |
Question Link: https://leetcode.com/problems/sort-colors/
Example 1:
Input: nums = [2,0,2,1,1,0]
Output: [0,0,1,1,2,2]
Example 2:
Input: nums = [2,0,1]
Output: [0,1,2]
Example 3:
Input: nums = [0]
Output: [0]
Example 4:
Input: nums = [1]
Output: [1]
Constraints:
n == nums.length
1 <= n <= 300
nums[i] is 0, 1, o... | ALGO | 0.999732 | 5.796558 |
32e128c6-cd4b-46af-b151-7c683e82e24a | ishandutta2007/codeforces | axiomofchoice/normal/1343/E.cpp | #include <bits/stdc++.h>
using namespace std;
#define repeat(i,a,b) for(int i=(a),_=(b);i<_;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,_=(a);i>=_;i--)
int cansel_sync=(ios::sync_with_stdio(0),cin.tie(0),0);
const int N=200010; typedef long long ll; const int inf=~0u>>2; const ll INF=~0ull>>2; ll read(){ll x; if(sc... | ALGO | 0.99971 | 4.504109 |
8c9920d6-eed7-4c7d-8355-8373154c9169 | PedroAngeli/Competitive-Programming | Solutions/Atcoder/Contests/AtCoder Beginner Contest 183/f.cpp | #include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define endl '\n'
#define f first
#define s second
#define ub upper_bound
#define lb lower_bound
#define pb push_back
#define all(c) (c).begin(), (c).end()
#define ... | ALGO | 0.999897 | 4.49101 |
0229aa3f-bf00-4ef4-90fd-520c62fa2d8f | Precipitating/LeetCode | Group the People Given the Group Size They Belong To/Source.cpp | #include <iostream>
#include <vector>
#include <unordered_map>
using namespace std;
class Solution
{
public:
vector<vector<int>> groupThePeople(vector<int>& groupSizes)
{
vector<vector<int>> result;
unordered_map<int, vector<int>> groups;
for (size_t i = 0; i < groupSizes.size(); ++i)... | ALGO | 0.999897 | 6.046657 |
f161b684-6ffb-4155-aaac-bc7a02a95e48 | lyciumlee/learn_leetcode_easy | Arranging Coins.cpp | #include<math.h>
using namespace std;
class Solution {
public:
int arrangeCoins(int n)
{
return (int)(((-1 + sqrt(1 + 8 * (long)n)) / 2));
}
}; | ALGO | 0.999904 | 5.586111 |
5a904c24-3587-49a2-a429-e88f551a9e7a | wendazhou/nbodyhpc | kdtree/src/cpp/tests/test_floyd_rivest.cpp | #include <kdtree/floyd_rivest.hpp>
#include <algorithm>
#include <vector>
#include <Random123/philox.h>
#include <gtest/gtest.h>
#include <kdtree/kdtree_build_opt.hpp>
#include <kdtree/kdtree_impl.hpp>
#include <kdtree/kdtree_utils.hpp>
namespace {
template <typename It, typename Fn> void fill_random(It beg, It en... | TEST | 0.970556 | 7.024533 |
b88e461d-2f79-4ce3-b361-507a194ae462 | kmjp/procon | leetcode/301-350/305/2368.cpp | typedef signed long long ll;
#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) me... | ALGO | 0.99989 | 5.107357 |
c6ce2664-2c2f-4877-a1c1-e1e368289b83 | faheemmuhammed1133/leetcode | 3324-split-the-array/split-the-array.cpp | class Solution {
public:
bool isPossibleToSplit(vector<int>& nums) {
unordered_map<int,int> freq;
for (int x : nums) {
if (++freq[x] > 2) {
return false;
}
}
return true;
}
}; | ALGO | 0.999418 | 5.791219 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.