uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
eab6d8ac-efa4-453e-81f2-6ab16fae4aef | rounakraj401/CRACK-INTERN | 1074-number-of-submatrices-that-sum-to-target/1074-number-of-submatrices-that-sum-to-target.cpp | class Solution {
public:
int numSubmatrixSumTarget(vector<vector<int>>& mat, int tar) {
int n=mat.size();
int m=mat[0].size();
for(int i=0;i<n;i++)
{
for(int j=1;j<m;j++)
{
mat[i][j]+=mat[i][j-1];
}
}
int c... | ALGO | 0.999986 | 6.457179 |
790681de-1526-482a-b0ef-dc8bbd446869 | ksgeu0905/Practice_Questions | Easy level/linked list/Next_greater_element_in_list.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* reverse_list(Li... | ALGO | 0.999889 | 5.002491 |
287cd50a-d23f-4483-acba-5b5aee2fb00e | Chakit22/Code_Library | At_coder_dp_tasks/frog_1_dp_bottom_up.cpp | #include<bits/stdc++.h>
using namespace std;
int main() {
int n;
cin >> n;
int dp[n + 1];
int h[n + 1];
h[0] = INT_MIN; //this is inititalized as INT_MIN so that when end =2 then end-2 will be 0 so as h[0] will store INT_MIN any value
for (int i = 1; i <= n; ++i)
cin >> h[i];
dp[0] = dp[1] = 0; //to reach 1 f... | ALGO | 0.999967 | 4.074541 |
447bb3d9-66b8-4eca-9460-2e23188993c1 | GXDE-OS/opencv-mobile | opencv-4.5.4/modules/features2d/src/evaluation.cpp | /
#include "precomp.hpp"
#include <limits>
using namespace cv;
template<typename _Tp> static int solveQuadratic(_Tp a, _Tp b, _Tp c, _Tp& x1, _Tp& x2)
{
if( a == 0 )
{
if( b == 0 )
{
x1 = x2 = 0;
return c == 0;
}
x1 = x2 = -c/b;
return 1;
}
... | ALGO | 0.999596 | 5.624839 |
bd17f8f5-1ba9-47d9-b9d0-e974ee88ee5d | 22026559NguyenThuyQuynh/BT_hackerank | BT_07/Bai_1.cpp | // binary search
#include<iostream>
using namespace std;
// tim index cua val trong arr[]
int bin_search( int arr[], int N, int val ){
int low = 0;
int high = N;
int mid = (low + high) / 2;
do{
if( arr[mid] == val ) return mid;
else if( arr[mid] > val ){
high = mid - 1;
... | ALGO | 0.999963 | 5.008944 |
f567be38-f767-45d0-b18e-e963bf979989 | JabedWeb/Basic_Problem_Solving | DataStructure/Final_Exam/Count_Me.cpp | /*
Problem Statement
You will be given a string S which will contain Lowercase, Uppercase English alphabets and spaces. You need to tell which word occurs the most times and also the count of that word.
Note: If there are multiple word which occurs the most, print the first word which became the maximum count before ... | ALGO | 0.99992 | 5.703108 |
6734cce2-444a-4bde-8b1e-b9e2f6b659b4 | bramkuijper/stress | src/ibm/stress.cpp | // the evolution of the stress response in a fluctuating envt
// Bram Kuijper
//
// important libraries
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <vector>
#include <... | ALGO | 0.998672 | 6.163529 |
40f2a9e7-f15c-4b3f-b1ab-045f22f10475 | abishpius/Coursera_Algos | Algorithmic_ToolBox/week3_greedy_algorithms/2_maximum_value_of_the_loot/fractional_knapsack.cpp | #include <iostream>
#include <vector>
using std::vector;
double get_optimal_value(int capacity, vector<int> weights, vector<int> values) {
double value = 0.0;
// write your code here
return value;
}
int main() {
int n;
int capacity;
std::cin >> n >> capacity;
vector<int> values(n);
vector<int> weig... | ALGO | 0.999885 | 4.860849 |
842a647f-f209-4766-beb7-d969423cfd38 | SHRESTHGUPTA89/leetcode | 0112-path-sum/0112-path-sum.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.999977 | 6.735226 |
60208659-7f8a-4e26-a3a5-8f2f795d9c5d | RushilAlagh/DSA-CPP | Leetcode/PeakIndexMountainArray.cpp | #include<iostream>
using namespace std;
int main(){
int n;
cout<< "Enter number of elements of array ";
cin>> n;
int arr[10];
for(int i = 0; i<n; i++){
cin>> arr[i];
}
int start = 0;
int end = n - 1;
int mid = start + (end-start)/2;
while(start<=end){
... | ALGO | 0.99972 | 3.91213 |
1ade6c36-a971-4923-8c79-608b3a0d06a4 | righthand0521/LeetCode | src/3480.cpp | #include <algorithm>
#include <iostream>
#include <limits>
#include <vector>
using namespace std;
class Solution {
public:
long long maxSubarrays(int n, vector<vector<int>>& conflictingPairs) {
long long retVal = 0;
vector<int> bMin1(n + 1, numeric_limits<int>::max());
vector<int> bMin... | ALGO | 0.99961 | 5.909229 |
94c06082-7a37-473e-986f-e24ad3cf24e9 | solimul/solana-bmc | cadical/test/api/example_constraint.cpp | #include "../../src/cadical.hpp"
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <cassert>
// This is the example from the header file
int main () {
CaDiCaL::Solver *solver = new CaDiCaL::Solver;
// ------------------------------------------------------------------
// Encode Problem and check without assumptions.... | ALGO | 0.968099 | 7.185374 |
2bd45bde-3390-43bd-ba20-18a339d27538 | CodeRitik189/LeetCodeRepo | 56-merge-intervals/56-merge-intervals.cpp | class Solution {
public:
vector<vector<int>> merge(vector<vector<int>>& itv) {
vector<vector<int>> ans;
sort(itv.begin(), itv.end());
int st = itv[0][0];
int end = itv[0][1];
for(int i=1; i<itv.size(); i++){
if(itv[i][0]>end){
ans.p... | ALGO | 0.999998 | 5.592663 |
625944cb-4145-4de7-ab5e-00f57e790084 | Shivam2501/MSI-GEM5 | src/systemc/tests/systemc/misc/unit/data/datawidth_unsigned/lost_carry/datawidth.cpp | /*****************************************************************************
datawidth.cpp --
Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15
*****************************************************************************/
/**************************************************************************... | ALGO | 0.958807 | 5.344794 |
c44d3c28-d853-41c9-9516-cf49c33f104b | Prayash007/All_my_codes | practice/JaggedSwaps.cpp | #include<bits\stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t-->0)
{
int n;
cin>>n;
vector<int>vec;
int n1;
cin>>n1;
vec.push_back(n1);
int mini=n1;
for (int i = 1; i < n; i++)
{
int num;
cin>>num;
vec.push_back(num);
min... | ALGO | 0.999898 | 3.59731 |
0b9ab0ac-5a8c-475b-90cb-508e39297ad0 | geekboxzone/mmallow_external_llvm | lib/Analysis/CFG.cpp | #include "llvm/Analysis/CFG.h"
#include "llvm/ADT/SmallSet.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/IR/Dominators.h"
using namespace llvm;
/// FindFunctionBackedges - Analyze the specified function to find all of the
/// loop backedges in the function and return them. This is a relatively cheap
/// (com... | ALGO | 0.999672 | 7.545222 |
5943634c-4187-4b58-8c7b-ef16a9f08a05 | JadedBeast/Codeforces | 527/A.cpp | // In the name of **** God ****
#include <bits/stdc++.h>
using namespace std;
#define ll long long
inline void JadedBeast() {
ios::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
}
const long long MAX=3e3+1;
ll dp(ll a, ll b){
if(a==0 or b==0)
return ... | ALGO | 0.999594 | 4.078594 |
3f14d757-bc3d-4735-9a47-47fd095ba8ba | PickAndEat/App | 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.9988 | 6.76073 |
6b096347-2ddd-4974-becd-39863766f94a | MarcelSimader/FERAT | deps/cadical/src/queue.cpp | #include "internal.hpp"
namespace CaDiCaL {
// Slightly different than 'bump_variable' since the variable is not
// enqueued at all.
inline void Internal::init_enqueue (int idx) {
Link &l = links[idx];
if (opts.reverse) {
l.prev = 0;
if (queue.first) {
assert (!links[queue.first].prev);
links... | ALGO | 0.998085 | 7.369824 |
7443076b-d7b4-48e1-9f4b-7cd0d5ee065a | ThreeSR/LeetCode | LC53_Maximum Subarray_DP.cpp | class Solution {
public:
int maxSubArray(vector<int>& nums) { // 动态规划
if (nums.size() == 0) return 0; // 特判
vector<int> dp(nums.size(),0); // dp的初始化
int result; // 存放最大结果
dp[0] = nums[0];
result = nums[0];
for (int i = 1; i < nums.size(); ++i){
dp[i] = max... | ALGO | 0.999992 | 6.02767 |
04f2af43-0d48-4635-ab3f-700f5d71d49b | Guilhem-Poties/IMAC-S2 | TD05/src/hachage.cpp | #include "hachage.hpp"
size_t folding_string_hash(std::string const& s, size_t max) {
size_t hash {0};
for (std::string::const_iterator it = s.begin(); it < s.end(); it++) hash+=*it;
return hash % max;
}
size_t folding_string_ordered_hash(std::string const& s, size_t max) {
size_t hash {0};
... | ALGO | 0.943191 | 5.925231 |
ac3b0bb9-3f00-417e-9a15-1fdd7e421623 | shreyarawat16/leetcode-challenge | Difficulty: Medium/N Digit numbers with digits in increasing order/n-digit-numbers-with-digits-in-increasing-order.cpp | //{ Driver Code Starts
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
// User function Template for C++
class Solution {
public:
void solve(int n, vector<int>& v, vector<int>& ans){
if(n==0){
int val=0;
for(int i=0; i<v.size(); i++){
val= val*10+ v[... | ALGO | 0.999794 | 7.26055 |
3b38515f-3a20-4828-8756-f96f8258cbf4 | jw0r1n/coleetde | code/a1046.cpp | #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <numeric>
using namespace std;
int main(int argc, const char * argv[]) {
ios::sync_with_stdio(false);
cin.tie(nullptr);
long long ni, mi, sum = 0;
cin >> ni;
vector<long long> v(ni + 1);
for(... | ALGO | 0.999967 | 4.275635 |
ffae2ad8-eea6-434c-8fb7-bffddb0e3547 | xolbynz/study_cpp | cpp/129.cpp | #include "stdafx.h"
#include <iostream>
#include <stdarg.h>
using namespace std;
int Sum(int arg, ...)
{
va_list ap;
va_start(ap, arg);
int sum = 0;
for (int i = 0; i < arg; i++)
sum += va_arg(ap, int);
va_end(ap);
return sum;
}
int main()
{
int number = Sum(5, 1, 2, 3, 4, 5);
cout << "1 5 : " << nu... | TOOL | 0.909341 | 4.676437 |
a8b5abec-a5f3-45f1-bed9-d3bce4f18864 | nihal866/Codeforces_Questions | A_Vanya_and_Fence.cpp | #include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fri(i, a, b) for(ll i = a; i < b; i++)
#define frd(i, a, b) for(ll i = a; i >= b; i--)
#define g(a,b) __gcd(a,b)
#define lcm(a,b) (a*b)/g(a,b)
#define lb(v,key) lower_bound(v.begin(), v.end(), key)
#define ub(v,key) upper_bound(v.begin(), v.end()... | ALGO | 0.999551 | 3.657178 |
6c16ae24-f836-41d2-8896-71227a67a76e | ayushxpal/C-.essentials | summer work/sawaal.cpp | // // // // // // // #include <iostream>
// // // // // // // using namespace std;
// // // // // // // int main(){
// // // // // // // int i,arr[]={1,2,3,8,5};
// // // // // // // int max=0;
// // // // // // // for(i=0;i<5;i++)
// // // // // // // {
// // // // // // // if( max < arr[i])
//... | ALGO | 0.994657 | 3.974063 |
f136ac34-7a1e-4ecf-a665-1e77726201bb | Sujal3013/CP-practice | Maths/1476A.cpp | #include <bits/stdc++.h>
using namespace std;
int main()
{
int t = 1;
cin >> t;
while (t--)
{
// Your code starts here
int n, k;
cin >> n >> k;
int max_num = k / n;
if (n > k)
{
if (n % k == 0)
{
k = n;
}... | ALGO | 0.999856 | 4.442508 |
8edd07b6-67a7-4813-a8be-d81f099061ea | HarshaVardhan31012007/Leetcode-and-Gfg-Codes | 0207-course-schedule/0207-course-schedule.cpp | class Solution {
public:
//Valid topological sort means no cycle hence we should check cycle present or not
//By BFS
void topoSort(vector<vector<int>>& prerequisites,vector<int>&ans,int n){
vector<int>indegree(n);
queue<int>q;
for(auto &each:prerequisites){
indegree[each[... | ALGO | 0.999839 | 6.409053 |
3ef813b4-b82b-4788-a145-1f3642ce8ed3 | aleafall/DS-A | leetcode/lc0113.cpp | //
// Created by t-xiuyan on 8/26/2017.
//
#include <iostream>
#include <vector>
using namespace std;
struct TreeNode {
int val;
TreeNode *left;
TreeNode *right;
TreeNode(int x) : val(x), left(NULL), right(NULL) {}
};
class Solution {
public:
vector<vector<int>> ans;
vector<vector<int>> pathSum(TreeNode *roo... | ALGO | 0.99991 | 5.832971 |
a66800a2-eb63-4f62-a939-f4d649f7ee61 | ishandutta2007/codeforces | okwedook/normal/1019/A.cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll n,m;
ll others_max(ll limit, vector<vector<ll> > parties){
//cout<<limit<<"->";
ll my_votes = parties[1].size();
ll res = 0;
vector<ll> left;
for(ll i=2; i<=m; i++){
while(parties[i].size() > limit){
res += ... | ALGO | 0.999786 | 3.646598 |
ab5afdfe-1cd1-4a78-b65d-98a06411a604 | NREL/AirflowNetwork | dependencies/eigen-eigen-323c052e1731/doc/examples/Tutorial_BlockOperations_block_assignment.cpp | #include <Eigen/Dense>
#include <iostream>
using namespace std;
using namespace Eigen;
int main()
{
Array22f m;
m << 1,2,
3,4;
Array44f a = Array44f::Constant(0.6);
cout << "Here is the array a:" << endl << a << endl << endl;
a.block<2,2>(1,1) = m;
cout << "Here is now a with m copied into its cent... | ALGO | 0.983935 | 3.329043 |
e371310b-c2d8-453a-8c3c-95c6cfad7bfe | Anup50/assignmentt | 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 |
0858e0fb-aff2-4ec5-9894-e8ed131b9c63 | TimKingNF/leetcode | test/cn/_63.gu-piao-de-zui-da-li-run-lcof.cpp | //
// Created by <EMAIL> on 2020/6/23.
//
#include "gtest/gtest.h"
#include "header.h"
#include "_63.gu-piao-de-zui-da-li-run-lcof.h"
namespace LeetCode_63 {
typedef vector<int> ArgumentType;
typedef int ResultType;
typedef tuple<ArgumentType, ResultType> ParamType;
class LeetCode_63Test : public ::testing::TestWit... | TEST | 0.989247 | 5.486058 |
082c6d01-099e-4bf1-90b1-d3796d979567 | AbdulrahmanJ204/cp | B_Monsters_Attack.cpp | #include <bits/stdc++.h>
using namespace std;
#define test \
int t; \
cin >> t; \
while (t--)
#define ll long long
#define endl '\n'
#define cendl cout << endl
#define cyes cout << "YES" << endl
#define cno cout << "NO" << endl
#define InTheNameOfAllah \
ios_base::sync_with_stdio(0); \
... | ALGO | 0.999972 | 3.613401 |
e8ea8e32-b3cf-4ae4-abb9-fe0e97ba81b8 | MU7L/XidianCS-2020 | 2020秋-计算机导论与程序设计/612/183_gcd.cpp | #include <stdio.h>
int main() {
int m, n, A, a;
scanf("%d %d", &m, &n);
if (m < n) {
a = m;
} else {
a = n;
}
while (m % a != 0 || n % a != 0) {
a--;
}
A = m * n / a;
printf("%d %d", a, A);
return 0;
} | ALGO | 0.999961 | 4.296974 |
b1b0320b-3824-4a08-a5df-4f9f0f8edb1c | AYUSH-MUKATI/Data-Structure-and-Algorithm | Arrays_Max_Value_In_Array.cpp | #include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
int a[n];
int max = INT_MIN;
for (int i = 0; i < n; i++)
{
cin>>a[i];
}
for (int i = 0; i < n; i++)
{
if(a[i]>max){
max = a[i];
}
}
cout<<max;
} | ALGO | 0.999816 | 3.617765 |
5b0a5b93-41b7-4c1f-8d25-ecaf72ab4178 | gomandev/kadio | src/Kadio.cpp | #include "Kadio.h"
double Kadio::Calculate(double x, char oper, double y)
{
switch(oper)
{
case '+':
return x + y;
case '-':
return x - y;
case '*':
return x * y;
case '/':
return x / y;
default:
return 0.0;
... | TOOL | 0.988146 | 4.580648 |
8cc47084-9f3b-4ca0-932e-4532ec5fca03 | tsssni/data-structure | Group_Package.cpp | #include<bits/stdc++.h>
using namespace std;
int sol[105][105],f[20005];
int main(){
std::ios::sync_with_stdio(false);
int s,n,m;
cin>>s>>n>>m;
for(int i=1;i<=s;i++)
for(int j=1;j<=n;j++){
cin>>sol[j][i];
sol[j][i]=sol[j][i]*2+1;
}
for(int i=1;i<=n;i++)
sort(sol[i]+1,sol[i]+s+1);
for(int i=1;i<=n;i++)... | ALGO | 0.999938 | 3.195077 |
4f26c91d-d5ed-421b-b254-63ade247ae9c | gaurav7902/The-First-One | Lab Assignments/Assignment-13_Q1.cpp | #include<stdio.h>
int main(){
int n,i=-1,j=-1;
printf("enter the size of the array\n");
scanf("%d",&n);
int a[n];
printf("enter the elements in sorted order\n");
for(i=0;i<n;i++){
scanf("%d",&a[i]);
}
int t,start=0,end=n-1,mid,temp;
printf("enter the target\n");
scanf("%d",&t);
i=0;
while(start<=end){
mid=(start+... | ALGO | 0.999703 | 3.928403 |
5237fb1a-dd34-45ee-a136-21c0874daf7d | anishsingh234/GeeksforGeeks | Difficulty: Basic/Greatest of three numbers/greatest-of-three-numbers.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 greatestOfThree(int a, int b, int c) {
// code here
int ab=a-b;
int flag = (ab >> 31) & 1;
int ma... | ALGO | 0.999838 | 5.792111 |
1a6ee065-a323-4031-8421-6590964885b3 | IslamAmr155/Problem-Solving | LeetCode/Easy/1137. N-th Tribonacci Number.cpp | class Solution {
public:
int tribonacci(int n) {
if (n == 0)
return 0;
else if (n == 1 || n == 2)
return 1;
int t0 = 0;
int t1 = 1;
int t2 = 1;
int t3 = t0 + t1 + t2;
for (int i = 3;i<n;i++)
{
t0 = t1;
t1... | ALGO | 0.999989 | 6.052909 |
34ad72a7-162a-4d18-9efb-3e7c52a3d36d | jiminAn/Algorithm | Greedy Algorithm/BaekJoon_5585.cpp | #include <iostream>
#include <vector>
using namespace std;
int main(void) {
vector<int> v = { 500,100,50,10,5,1};
int money, change;
int answer = 0;
cin >> money;
change = 1000 - money;
for (int i = 0; i < v.size(); i++) {
while (change - v[i] >= 0) {
change -= v[i];
answer++;
}
if (change == 0)
... | ALGO | 0.999626 | 4.226778 |
d1731fd3-b387-4389-ab14-d82460343dd6 | oosquare/OI-Codes | Storage/Luogu/P1456-Monkey King.cpp | #include <iostream>
using namespace std;
constexpr int maxn = 1e5 + 10;
struct Node {
int ls, rs, fa, key, dis;
};
int n, m;
Node heap[maxn * 3];
int uuid, now[maxn], rev[maxn * 3];
void pushup(int x) {
if (heap[heap[x].ls].dis < heap[heap[x].rs].dis)
swap(heap[x].ls, heap[x].rs);
heap[x].dis =... | ALGO | 0.999986 | 4.274271 |
f89abf23-eb7a-42d1-bea2-79aefcf29053 | developertanvir2019/competitive_programming | div3_Contest/C_Dora_and_Search.cpp | #include <iostream>
#include <vector>
using namespace std;
void solve() {
int t; // Number of test cases
cin >> t;
while (t--) {
int n;
cin >> n;
vector<int> a(n);
for (int i = 0; i < n; ++i) {
cin >> a[i];
}
// Find global min and max
i... | ALGO | 0.999771 | 5.302871 |
d4a8013f-1843-43a8-942c-34506053530c | Sagarbha1991/com.example.trilinos | packages/muelu/example/advanced/multiplesolve/ReuseSequence.cpp | // Teuchos
#include <Teuchos_StandardCatchMacros.hpp>
// Galeri
#include <Galeri_XpetraParameters.hpp>
#include <Galeri_XpetraProblemFactory.hpp>
#include <Galeri_XpetraUtils.hpp>
#include <Galeri_XpetraMaps.hpp>
#include <MueLu.hpp>
#include <MueLu_Level.hpp>
#include <MueLu_Factory.hpp>
#include <MueLu_RAPFactory.... | TOOL | 0.927604 | 5.194522 |
36723aec-de23-4f3d-9f88-9e26c7ba47ba | peterosterlund2/tbcomp | lib/texellib/treeLogger.cpp | /*
* treeLogger.cpp
*
* Created on: Feb 25, 2012
* Author: petero
*/
#include "treeLogger.hpp"
#include "transpositionTable.hpp"
#include "textio.hpp"
#include "position.hpp"
#include "constants.hpp"
#include <iostream>
#include <iomanip>
#include <cassert>
void
TreeLoggerWriter::open(const std::string& f... | TOOL | 0.90787 | 6.233927 |
751bf9eb-5eef-4de6-afb7-d0f38c731a71 | fajartd02/Leetcode | Medium/PermutationInString.cpp | #include <bits/stdc++.h>
using namespace std;
class Solution {
public:
bool checkInclusion(string s1, string s2) {
if(s1.size() > s2.size()) return false;
int lenS1 = s1.size();
int lenS2 = s2.size();
vector<int> v1(26, 0);
vector<int> v2(26, 0);
... | ALGO | 0.999946 | 5.914962 |
4d30ac3e-1d34-4325-970e-2b0ce80cca48 | ValterYudi/competitive-programming | Codeforces/educacional/155/teste.cpp | #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
int main(){
ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
vector<int> v = {0, 2, 4, 6, 12, 14};
int n; cin >> n;
auto it = lower_bound(v.begi... | ALGO | 0.999945 | 3.937366 |
1472c269-c863-409d-879d-1f9bb9948727 | nimesh00/QR_CODE | samples/tapi/pyrlk_optical_flow.cpp | #include <iostream>
#include <vector>
#include <iomanip>
#include "opencv2/core/utility.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/videoio.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/core/ocl.hpp"
#include "opencv2/video/video.hpp"
using namespace std;
using namespace cv;
typedef unsigned char... | ALGO | 0.946323 | 5.716725 |
0b81d3ff-1b9b-4a5c-a718-77c9abb91625 | convict-git/sport_coding | educational_cf/codeforces.com/Codeforces_Educational_Codeforces_Round_30/E._Awards_For_Contestants/main.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;
#ifdef CONVICTION
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3... | ALGO | 0.999993 | 3.65814 |
6484174d-9dac-4882-862f-3a919f733ad4 | GameIUST4031/HW3_PoliceCar | Police_Car/Library/PackageCache/com.unity.ide.visualstudio@2.0.16/Editor/COMIntegration/COMIntegration~/COMIntegration.cpp | #include <iostream>
#include <sstream>
#include <string>
#include <filesystem>
#include <windows.h>
#include <shlwapi.h>
#include <fcntl.h>
#include <io.h>
#include "BStrHolder.h"
#include "ComPtr.h"
#include "dte80a.tlh"
constexpr int RETRY_INTERVAL_MS = 150;
constexpr int TIMEOUT_MS = 10000;
// Often a DTE call m... | TOOL | 0.938866 | 6.957276 |
c072cb03-8b11-47a5-9b96-1c7e340b1cf0 | alaminmiah4274/Data_Structure | binary_tree_operations/leaf_node_count_binary_tree.cpp | #include <bits/stdc++.h>
using namespace std;
class Node
{
public:
int value;
Node *left;
Node *right;
Node(int value)
{
this->value = value;
this->left = NULL;
this->right = NULL;
}
};
Node *input_binary_tree()
{
int val;
cin >> val;
Node *root;
if (v... | ALGO | 0.999428 | 5.049917 |
556bca13-5a46-4a70-bef4-2e7a502c9494 | JooseRajamaeki/ICP | DistributionMapper/eigen_332/doc/snippets/EigenSolver_EigenSolver_MatrixType.cpp | MatrixXd A = MatrixXd::Random(6,6);
cout << "Here is a random 6x6 matrix, A:" << endl << A << endl << endl;
EigenSolver<MatrixXd> es(A);
cout << "The eigenvalues of A are:" << endl << es.eigenvalues() << endl;
cout << "The matrix of eigenvectors, V, is:" << endl << es.eigenvectors() << endl << endl;
complex<double> l... | ALGO | 0.999527 | 3.093769 |
20965f0f-6ffe-4fa1-adc9-006511a9d07a | saif-islam-rayhan/Codeforces_problem | A. Ideal Generator.cpp | #include <iostream>
using namespace std;
int main() {
int t;
cin >> t;
while (t--) {
int k;
cin >> k;
if (k % 2 == 1) {
cout << "YES\n";
} else {
cout << "NO\n";
}
}
return 0;
}
| ALGO | 0.999208 | 5.436382 |
4a3e4a0e-3f35-46aa-9faf-38d0fa5a2646 | shoujiaxin/leetcode-solutions-cpp | [103] Binary Tree Zigzag Level Order Traversal/solution1.cpp | /*
* @lc app=leetcode id=103 lang=cpp
*
* [103] Binary Tree Zigzag Level Order Traversal
*
* https://leetcode.com/problems/binary-tree-zigzag-level-order-traversal/description/
*
* algorithms
* Medium (45.41%)
* Likes: 1607
* Dislikes: 85
* Total Accepted: 311.4K
* Total Submissions: 685.2K
* Testcas... | ALGO | 0.999992 | 6.952579 |
d2cb4db8-8e33-43ca-9214-3889266eebd4 | electro1rage/OJProblemsCodes | Problem Storage/Greedy/Easy/Proofed/CF_Div2_276D.cpp | #include <bits/stdc++.h>
using namespace std;
int bit(long long x, long long i) {
return (x >> i) & 1;
}
int main() {
long long l, r;
cin >> l >> r;
long long ans = 0;
for (int i = 60; i >= 0; --i) {
if (bit(r, i) && !bit(l, i)) {
ans = (1LL << (i + 1)) - 1;
break;
}
}
cout << ans << endl;
return ... | ALGO | 0.999429 | 3.364768 |
2d16b233-fbad-49ab-9cff-d0a4b2d86417 | mewmintlabs/mewmint | src/consensus/merkle.cpp | #include <consensus/merkle.h>
#include <hash.h>
/* WARNING! If you're reading this because you're learning about crypto
and/or designing a new system that will use merkle trees, keep in mind
that the following merkle tree algorithm has a serious flaw related to
duplicate txids, resulting in a ... | ALGO | 0.999639 | 7.432685 |
86ca9ae1-573a-42c1-9717-545dc83100f0 | n1ckfg/latk_ml_003 | SynDraw/SynDraw/libigl/include/igl/copyleft/cgal/intersect_with_half_space.cpp | #include "intersect_with_half_space.h"
#include "mesh_boolean.h"
#include "half_space_box.h"
template <
typename DerivedV,
typename DerivedF,
typename Derivedp,
typename Derivedn,
typename DerivedVC,
typename DerivedFC,
typename DerivedJ>
IGL_INLINE bool igl::copyleft::cgal::intersect_with_half_space(
... | ALGO | 0.996302 | 6.76227 |
003c1be1-8a6e-4762-a8a8-850cd1f26ae5 | atharva7803/Logic-Building-and-DSA-in-C-CPP-JAVA | Problems On Recursion/Program186.cpp | #include<iostream>
using namespace std;
int DisplaySum(int iNo){
int iSum = 0;
while(iNo > 0){
iSum += iNo;
iNo--;
}
return iSum;
}
int main(){
int iValue = 0, iRet = 0;
cout<<"Enter number: "<<endl;
cin>>iValue;
iRet = DisplaySum(iValue);
cout<<"Addition is: "<... | ALGO | 0.99729 | 4.116872 |
63edab69-d600-4951-bbcf-f4db6b63eb12 | EmcsiCodes/Competitive-Programming | Contests/Nemes Tihamer/Zsakfalva/main.cpp | #include <iostream>
#include <vector>
#include <queue>
using namespace std;
/*
**Problem Summary:**
Given a road network connecting villages in a county, identify the villages that act as dead-ends (only one road leading in or out) and from which, when starting, you can pass through the maximum number of villages whe... | ALGO | 0.999941 | 6.059145 |
c4c4e3b8-a92f-4167-93e7-9b1375128d4b | StathisChatziloizos/CGAL-Polygon-Optimization | Project1_Polygonization/sharedLib.cpp | #ifndef __SHARED_LIB_CPP__
#define __SHARED_LIB_CPP__
#include "sharedLib.h"
void printPolygon(Polygon_2 points)
{
for (Point_2 p : points)
std::cout << p << std::endl;
}
int findPolygonPoint(Polygon_2 polygon, Point_2 point)
{
int index = -1;
for (int i = 0; i < polygon.size(); i++)
{
... | TOOL | 0.986087 | 6.658199 |
c4ac4b6d-471a-43db-95f7-95ac91f72723 | ishandutta2007/codeforces | golovanov399/normal/843/B.cpp | #include <bits/stdc++.h>
#define itn int
#define all(x) (x).begin(), (x).end()
#ifdef ONLINE_JUDGE
inline int pidorand() {
return ((rand() & 32767) << 15) | (rand() & 32767);
}
inline int aimteh_rand() {
return pidorand() ^ (pidorand() + 2281488);
}
#define rand aimteh_rand
#endif // ONLINE_JUDGE
#ifdef OLB... | ALGO | 0.999976 | 3.360011 |
d8f1b9dc-ee11-4f81-86b0-b8c0ebc8ca63 | 0xb1b1/cpp-courses | misis-itkn/semester_1/hw_4/hw_4-lv_3-ex_10/main.cpp | #include <iostream>
using namespace std;
int main() {
// Input data
int rows = 6, columns = 7;
int input_matrix[rows][columns] = {{3,3,2,4,1,3,1},
{1,2,4,4,1,4,2},
{4,2,4,2,6,1,9},
{3,6... | ALGO | 0.99975 | 4.686858 |
ccbb5d63-f80c-402e-b8e1-2f536d6c8168 | joeyst/snn-vis-graphics | utils.cpp |
#include "utils.h"
#include "cstdlib"
#include <random>
std::pair<PointCoords3D, PointCoords3D> GetConnectionEndpoints(const PointCoords3D& start, const PointCoords3D& end, float segmentPercent) {
PointCoords3D resultStart(3);
PointCoords3D resultEnd(3);
for (size_t i = 0; i < 3; ++i) {
resultStart[i] = st... | ALGO | 0.985458 | 5.735599 |
c3ee60e0-ee07-4de2-b791-6d1d2588f888 | PriyanshuGupta1/Leetcode | 1679-max-number-of-k-sum-pairs/1679-max-number-of-k-sum-pairs.cpp | class Solution {
public:
int maxOperations(vector<int>& nums, int k) {
int n = nums.size();
unordered_map<int, int> freqMap;
int ans = 0;
for(int i = 0 ; i < n ; i++){
if(freqMap[k - nums[i]] > 0){
ans++;
freq... | ALGO | 0.999951 | 6.221147 |
57ecb558-15ff-4eae-a8ac-cc860bc5f571 | hack-parthsharma/LeetCode | 2601-prime-subtraction-operation/2601-prime-subtraction-operation.cpp | class Solution {
public:
bool primeSubOperation(vector<int>& nums) {
constexpr int kMax = 1000;
const vector<int> primes = sieveEratosthenes(kMax);
int prevNum = 0;
for (int num : nums) {
// Make nums[i] the smallest as possible and still > nums[i - 1].
const auto it = lower_bound(begin(... | ALGO | 0.999919 | 5.82672 |
7859f73d-9cd3-4d66-8f66-4646714fb393 | kaziabdullahfuad/Codeforces-Grind | contest/round 971 (div-4)/A.cpp | #include<iostream>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#include<unordered_set>
#include<unordered_map>
#include<map>
using namespace std;
#define ll long long
#define endl "\n"
#define debug(x) cout<<#x<<":"<<x<<endl;
#define all(x) (x).begin(),(x).end()... | ALGO | 0.999628 | 3.864826 |
00bfa762-4a37-4133-9024-b1d3e5060e27 | harshit-singhh/DSA-QUESTIONS | 2502-sort-the-people/2502-sort-the-people.cpp | class Solution {
public:
vector<std::string> sortPeople(vector<string>& names, vector<int>& heights) {
int n = names.size();
unordered_map<int, string> mapping;
for (int i = 0; i < n; ++i) {
mapping[heights[i]] = names[i];
}
sort(heights.rbegin(), heights.rend()... | ALGO | 0.999972 | 6.535496 |
98468c34-8a84-4668-a153-655c5b8e6417 | Sunny9507/dsa | 0957-minimum-add-to-make-parentheses-valid/0957-minimum-add-to-make-parentheses-valid.cpp | class Solution {
public:
int minAddToMakeValid(string s) {
int cnt = 0;
stack<char>st;
for(char c: s){
if(c == '(') st.push(c);
else {
if(st.empty()) cnt++; // koi tha hi nhi
else st.pop();
}
}
return cnt + ... | ALGO | 0.999324 | 6.016359 |
170553b1-f159-4228-abe2-74b319bcbd41 | wolf5x/interview | leetcode/039_CombinationSum.cpp | // 20min, 1WA
// naive dfs
class Solution {
vector<vector<int>> ans;
vector<int> cands;
public:
vector<vector<int> > combinationSum(vector<int> &candidates, int target) {
sort(candidates.begin(), candidates.end());
candidates.resize(unique(candidates.begin(), candidates.end())-candidates.beg... | ALGO | 0.999985 | 5.943681 |
ed6c98a1-af12-4327-b93e-f8c3fed8d15f | Subham988/GFG_PotD | May/17th_May/Trace Path.cpp | class Solution{
public:
int isPossible(int n, int m, string s)
{
// code here
int side=0,niche=0,maxSide=0,minSide=0,maxNiche=0,minNiche=0;
for(auto x:s){
if(x=='R')
side++;
else if(x=='L')
side--;
else if(x=='U')
... | ALGO | 0.999861 | 5.624028 |
c54cc8ca-dc1f-4917-b9f4-081f0c159964 | NCCA/CFGAA | Lecture9STLandAlgorithms/Algorithm/transform.cpp | #include <iostream>
#include <list>
#include <vector>
#include <algorithm>
int main()
{
std::vector <int> myList;
myList.push_back(2);
myList.push_back(4);
myList.push_back(5);
myList.push_back(6);
myList.push_back(2);
std::vector <int> secondList;
secondList.resize(myList.size());
std::for_each(std::begi... | ALGO | 0.999225 | 4.079027 |
511cb449-6e8c-49a3-99c6-c038baa7d981 | tyabus/xray-1.0 | 3rd_party/boost/libs/graph/example/topo_sort.cpp | typedef std::pair<std::size_t,std::size_t> Pair;
/*
Topological sort example
The topological sort algorithm creates a linear ordering
of the vertices such that if edge (u,v) appears in the graph,
then u comes before v in the ordering.
Sample output:
A topological ordering: 2 5 0 1 4 3
*/
int
main(int ... | ALGO | 0.999431 | 6.249714 |
57736f9c-a53d-4faa-b916-329aec9ebed2 | iqbalalghifary/Silsilah_Kerajaan | a/linked.cpp | #include "linked.h"
boolean isEmpty(address p){
if(p == NULL){
return 1;
}else{
return 0;
}
}
void Create_Node (address *p){
*p = (address)malloc(sizeof(ElmtList));
if(p != Nil){
printf("Alokasi Berhasil dengan Alamat : %p.\n",*p);
}else{
printf("Gagal Alokasi\n");
}
}
void Isi_Node (address *p , ... | ALGO | 0.994803 | 3.576458 |
9efb90d7-be51-4fce-8366-4994298bec57 | BasedBoznie/Prog1 | drillek/drill21/drill21_set.cpp | #include <iostream>
#include <stdexcept>
#include <string>
#include <set>
#include <vector>
struct Fruit{
std::string name;
int quantity;
double unit_price;
Fruit(const std::string& n, int q = 0, double p = 0.0) : name(n), quantity(q), unit_price(p) {}
};
struct Fruit_ptr_cmp{
bool operator()(const Fruit* a, c... | ALGO | 0.98686 | 5.396487 |
853a44fe-46b1-42e4-9939-7f6699f14647 | qiaozishun4/CSP2024_BJ | BJ-Junior/answers/BJ-J00168/explore/explore.cpp | #include<bits/stdc++.h>
using namespace std;
long long t,n,m,k;
char a[1010][1010];
bool ismove[1010][1010];
int main(){
freopen("explore.in","r",stdin);
freopen("explore.out","w",stdout);
cin>>t;
while(t--){
cin>>n>>m>>k;
long long x,y,d,x1,y1;
cin>>x>>y>>d;
memset(a,0,s... | ALGO | 0.999849 | 4.207038 |
6a8a56d1-f84f-4225-8c13-abd620f425f2 | wassimalharaki/Codeforces | 900/ArrayStabilization.cpp | #include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define all(v) v.begin(), v.end()
#define nl << '\n'
#define v vector
#define vi vector<int>
#define pii pair<int, int>
#define mp make_pair
#define pb push_back
#define INF LONG_LONG... | ALGO | 0.99995 | 4.409306 |
2ed1a28e-02ea-4acf-a7e7-2bc97ada42a8 | Noor-Fatima-24/cpp-programming | cpp/practice-extra/practice-32/main.cpp | // Q15: Take n numbers in array, print all numbers, then their sum, then average.
#include<iostream>
using namespace std;
int main()
{
float avg;
int n,sum=0;
cout<<"Enter how many numbers u want to enter in the array : ";
cin>>n;
int arr[n];
cout<<"Enter "<<n<<" numbers in array : ";
... | ALGO | 0.984745 | 3.26301 |
82d681db-e28f-4cd6-abfe-a0a50c94991e | amorales2/HackerRank | ComparetheTriplets/Compare The Triplets/Compare The Triplets/main.cpp | #include <iostream>
int main() {
int a0;
int a1;
int a2;
std::cin >> a0 >> a1 >> a2;
int b0;
int b1;
int b2;
std::cin >> b0 >> b1 >> b2;
int totala = 0;
int totalb = 0;
if (a0 > b0)
{
++totala;
}
if (a1 > b1)
{
++totala;
}
if (a2 > b2)
{
++totala;
}
//bob
if (a0 < b0)
{
++totalb;
}
if... | ALGO | 0.999683 | 3.656111 |
e9424aed-1caf-43d6-a574-49aa0682ed55 | mehadi214100/C-Programming | All DUET QUESTION/2021_5_c.cpp | #include<bits/stdc++.h>
using namespace std;
int count (int num){
int c = 0;
while (num>0)
{
c++;
num/=10;
}
return c;
}
int main(){
int number;
cin>>number;
int original = number;
int reverse = 0;
while (number>0)
{
int last = number%10;
rev... | ALGO | 0.999939 | 5.114793 |
b78d1d49-86cd-4a06-aaac-999c60f8682b | Krishantchauhan/LeetCode | 709. To Lower Case.cpp | class Solution {
public:
string toLowerCase(string s) {
for(int i=0; i<s.length(); i++)
s[i]=tolower(s[i]);
return s;
}
}; | ALGO | 0.98824 | 5.081764 |
00e80165-463c-4104-aa80-6b23b9fef054 | mikejdorm/cpp_coursework | template_fibonacci/fib.cpp | #include<iostream>
using namespace std;
template<int i>
struct Fib {
static const int unsigned value = Fib<i-1>::value + Fib<i-2>::value;
};
template<>
struct Fib<0> {
static const int unsigned value = 0;
};
template<>
struct Fib<1> {
static const int unsigned value = 1;
};
int main()
{
cout << Fib<10>::val... | ALGO | 0.999519 | 4.768887 |
17bc7c50-69ef-486b-b5f1-66734337d9df | Dawidsoni/programming-competitions | Classic/graphs/Kruksal.cpp | #include<iostream>
#include<algorithm>
using namespace std;
class Edge {
public:
int dist, v1, v2;
Edge() {}
Edge(int v1_, int v2_, int dist_) : dist(dist_), v1(v1_), v2(v2_) {}
};
bool operator < (const Edge & e1, const Edge & e2) {
if(e1.dist < e2.dist) return true;
return false;
}
class Vertex... | ALGO | 0.999967 | 4.191145 |
dc25f7be-4b38-4ff4-be40-4736a17c8360 | Emiyazhang/PATprac | PATB/B1017.cpp | /*************************************************************************
> File Name: B1017.cpp
> Author: ji_zhang
> Mail:
> Created Time: 2017/11/15 2:04:01
************************************************************************/
#include<iostream>
using namespace std;
string bn,ans;
int main(){
... | ALGO | 0.999871 | 3.96727 |
3ee49386-8f68-4f6a-9da1-9b83b0f7e28e | jeongmin-0113/Baekjoon-Algorithm | [백준 1929] 소수 구하기.cpp | #include <iostream>
using namespace std;
int arr[1000001];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL); cout.tie(NULL);
int m, n; cin >> m >> n;
arr[1] = 1;
for (int i = 2; i <= n; ++i) {
if (arr[i] == 0) {
for (int j = 2; j * i <= n; ++j) {
arr[i * j] = 1;
}
}
}
for (int i = m; ... | ALGO | 0.999962 | 3.654314 |
8e6b9f8a-2cd9-481f-8a89-c8e48b5b0927 | homedory/codetree-TILs | 240215/겹치는 원소가 적은 부분 수열/subsequences-with-few-overlapping-elements.cpp | #include <iostream>
#include <unordered_map>
using namespace std;
#define MAX_N 100005
int main() {
int n, k;
int arr[MAX_N];
unordered_map<int,int> num_cnt;
cin >> n >> k;
for (int i = 1; i <= n; i++) {
cin >> arr[i];
}
int j = 0;
int ans = 0;
for (int i = 1; i <= n; i+... | ALGO | 0.999989 | 4.541706 |
abec3be0-d12b-413d-9633-6cc99aec95a6 | thebesttv/00.ACM | 50.c/aoapc-book-master/BeginningAlgorithmContests/exercises/ch5/UVa409.cpp | // UVa409 Excuses, Excuses!
// Rujia Liu
// 题意:输入k个关键字和e行文本,找出所有包含最多关键字的文本行。
// 细节:字母不区分大小写;连续字母串算一个单词(前后不一定是空格,可能是其他非字母字符);同一个关键字出现多次按多次算
#include<iostream>
#include<cstdio>
#include<string>
#include<set>
#include<sstream>
using namespace std;
const int maxn = 100;
int k, e, cnt[maxn];
set<string> keywords;
string e... | ALGO | 0.996859 | 3.714555 |
5d410288-d86f-4034-a181-184f2f135088 | 20125A0511/CPP | C++ Programs/New folder (30)/Untitled8.cpp | #include<iostream>
#include<string.h>
using namespace std;
int main()
{
char str[100];
int i, length;
int flag = 0;
cout<<"\n Enter String : ";
cin>>str;
length = strlen(str);
for(i=0;i < length ;i++)
{
if(str[i] != str[length-i-1])
... | ALGO | 0.998939 | 3.330537 |
722099f3-a6bf-498a-af51-770da4a4b410 | Priya-Thakur25/LeetCode | 0050-powx-n/0050-powx-n.cpp | class Solution {
public:
double findAns(double x, int n, double &ans){
if(n <= 0) return 1;
ans = findAns(x,n/2,ans);
if(n%2 == 0){
ans = ans * ans;
}
else{
ans = ans * ans * x;
}
return ans;
}
double myPow(double x, int n) {
double ans = 1;
if(x == 1) ret... | ALGO | 0.999959 | 5.619997 |
ae26b59a-3945-4685-b912-b6bef6cdc65a | ishandutta2007/codeforces | omer223/normal/1283/A.cpp | #define MOD 1000000007
#define fast ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define FOR(i, n) for (int i = 0; i < n; i++)
#define pb push_back
#define mp make_pair
#define has(set, x) set.find(x) != set.end()
#define nohas(set, x) set.find(x) == set.end()
#define inc(mpp, x) {if(has(mpp, x)) mpp[x]++; else... | ALGO | 0.998686 | 4.209131 |
1ae02ef3-9a1f-43da-b46c-17fc1fc04b59 | mohammedjasam/Technical-Interview-Guide | HackerRank/contacts.cpp | /*
*
* Tag: Data Structure (Trie) && DP
* Time: O(nm) where m is the average length of given string
* Space: O(n^26)
*/
#include <cmath>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <iostream>
#include <algorithm>
using namespace std;
const int NN = 30;
const int N = 3000100;
const i... | ALGO | 0.999529 | 4.623714 |
95eeeb27-5885-41f6-bd45-bc4227d40867 | lzhou835/leetcode | 329.Longest_Increasing_Path_in_a_Matrix.cpp | class Solution {
public:
vector<vector<int>> dir={{-1, 0}, {1, 0}, {0, 1}, {0, -1}};
int dfs(vector<vector<int>> & matrix, vector<vector<int>> & dp, int i, int j){
if(dp[i][j]) return dp[i][j];
int m=matrix.size(), n=matrix[0].size();
int mx=1;
for(auto d:dir){
i... | ALGO | 0.999994 | 6.189141 |
6dfd244b-c9bc-4bb1-8dc1-06c778693696 | ishandutta2007/codeforces | saost/normal/1737/B.cpp | #include <bits/stdc++.h>
#define FOR(i,l,r) for(int i=l; i<=r; ++i)
#define REP(i,l,r) for(int i=l; i<r; ++i)
#define FORD(i,r,l) for(int i=r; i>=l; --i)
#define REPD(i,r,l) for(int i=r-1; i>=l; --i)
using namespace std;
const int N = 100005;
int t, n, m, k, res;
int a[N], b[N], f[N];
long long l, r;
void Enter() {
... | ALGO | 0.999945 | 4.246228 |
e4e09f16-3225-41ca-966c-b6c98d05c357 | bittusharma3/dsa | 2 Learn sorting tech/2.2 Sorting -ll/quickSort.cpp | #include <bits/stdc++.h>
using namespace std;
int partition(vector<int> &arr, int low, int high)
{
int i = low;
int j = high;
int pivot = arr[low];
while (i < j)
{
while (arr[i] <= pivot && i <= high - 1)
{
i++;
}
while (arr[j] > pivot && j >= low + 1)
... | ALGO | 0.999912 | 4.651617 |
8b0d14ba-6b1c-4bd3-84a9-ff2a66f228ee | arin2002/Hacktoberfest-2022 | C++/Dynamic Programming/MCM_recursion_memoization.cpp | #include<bits/stdc++.h>
using namespace std;
/*
problem link = https://practice.geeksforgeeks.org/problems/matrix-chain-multiplication0303/1
*/
int solve(int *arr, int i, int j, vector<vector<int>> &memo){
if(i>=j){
return 0;
}
//
if(memo[i][j] != -1){
ret... | ALGO | 0.999985 | 4.139956 |
b99b50c3-b1d7-4de2-b9db-7392d8eb6821 | SumitTeerthani/DSA-Solutions | String/jewels_and_stones.cpp | class Solution
{
public:
int numJewelsInStones(string jewels, string stones)
{
unordered_set<char> s;
int ans = 0;
for (int i = 0; i < jewels.length(); i++)
{
char ch = jewels[i];
s.insert(ch);
}
for (int i = 0; i < stones.length(); i++)
... | ALGO | 0.99863 | 5.781477 |
3ccaa59a-ff1b-481a-946e-eef4ceab3b8a | teagoodilon/estrutura_de_dados | tads/praticas.cpp | #include <iostream>
#include <cstdlib>
using namespace std;
struct vectorx {
int* vetor;
int tam;
};
void inicializa(vectorx* vec, int n) {
vec->vetor = new int[n];
vec->tam = n;
}
void finaliza(vectorx* vec) {
delete[] vec->vetor;
vec->tam = 0;
}
void preenche(vectorx* vec) {
for (int i = 0; i < vec-... | ALGO | 0.997951 | 3.339143 |
45a08209-334b-4245-acb8-97db6e80c696 | yuristaindani/Tugas_Progmob | 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.9988 | 6.76073 |
5b95e652-77e4-4d1b-b6e0-b0a19baa0f0e | ssubrt/Leetcode-pots | July-5/Find the Minimum and Maximum Number of Nodes Between Critical Points.cpp | ------------>>>>>>>>>>>>> Approach <<<<<<<<<<<<<<-------------------
// time complexity of the code is O(n)
// space complexity of the code is O(n)
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x)... | ALGO | 0.999994 | 5.414993 |
386e213b-61ee-469a-96be-cb6909da6dfc | EmptyDust/Algorithm-Codes-and-writeups | codes/-0x30_competition/-0x33_codeforces/943/B.cpp | #include <bits/stdc++.h>
using i64 = long long;
constexpr int MAXN = 1e6 + 10, inf = 1e9, mod = 1e9 + 7;
int nums[MAXN], m, n;
using pt = std::pair<int, int>;
void solve() {
std::cin >> n >> m;
std::string s, t;std::cin >> s >> t;
int ans = 0;
for (int i = 0, j = 0;j < m && i < n;++j) {
if (s[i... | ALGO | 0.99996 | 5.222246 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.