uuid string | repo_name string | relative_path string | content string | category string | algo_rel_score float64 | quality_score float64 |
|---|---|---|---|---|---|---|
ebacb56e-bc62-4a19-b4a4-4146eed36db9 | muzamil9899/dsa-essential-course | 16 Queue/stack_using_queue.cpp | #include<iostream>
#include<stack>
#include<queue>
using namespace std;
//Implement a Stack Class, which uses 2 Queues internally as a data structure.
class Stack{
queue<int> q1,q2;
public:
void push(int x){
//will insert in the non-empty queue
if(!q1.empty()){
q1.push(x);
}
else{
q2.push(x);
}
}
... | ALGO | 0.999599 | 4.610072 |
e1bf39ba-7404-4ed7-b090-9b91d5ed9465 | WebClub-NITK/Hacktoberfest-2k17 | Sorting/Bubble_Sort/ankitgaur17.cpp | void bubbleSort(vector<int>& vec){
int temp;
for(int i=0; i<vec.size(); i++){
for(int j=0; j<vec.size()-i-1; j++)
if(vec[j] > vec[j+1]){
temp = vec[j];
vec[j] = vec[j+1];
vec[j+1] = temp;
}
}
}
| ALGO | 0.999409 | 5.085768 |
d1f7aae8-560a-4c46-ae53-408cb6e3325d | ajayAlways/Leetcode-solved-problems | 0380-insert-delete-getrandom-o1/0380-insert-delete-getrandom-o1.cpp | class RandomizedSet {
private:
unordered_map<int,int>Map;
vector<int>nums;
public:
RandomizedSet() {
Map.clear();
nums.clear();
}
bool insert(int val) {
if(Map.find(val)!=Map.end()) return false;
nums.push_back(val);
Map[val] = nums.size()-1;
retu... | ALGO | 0.999271 | 6.179833 |
f7a567f6-859d-4f02-bfb6-6e5457b5be1b | siddharth25pandey/Leetcode-Solution | 746-min-cost-climbing-stairs/746-min-cost-climbing-stairs.cpp | class Solution {
public:
int minCostClimbingStairs(vector<int>& cost) {
vector<int>dp=cost;
for(int i=2;i<cost.size();i++)
{
dp[i]+=min(dp[i-2],dp[i-1]);
}
return min(dp[cost.size()-1],dp[cost.size()-2]);
}
}; | ALGO | 0.999919 | 5.98808 |
2cf51efd-466f-4399-bbb3-d6ae93f4ac0c | Kaitogaming/CSES | Trailing-Zeros.cpp | #include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
long long ans=0;
int n;
cin>>n;
for(long long i=5;i<=n;i*=5)
{
ans+=n/i;
}
cout<<ans;
} | ALGO | 0.999868 | 3.729393 |
491cab3b-d221-43ca-bf7c-0a496b6b30db | ishandutta2007/codeforces | 2222/normal/13/E.cpp | #include <algorithm>
#include <iostream>
#include <sstream>
#include <complex>
#include <numeric>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <queue>
#include <cmath>
#include <map>
#include <set>
using namespace std;
#define all(a) (a).begin(),(a).end()
#define sz(a) int((a).s... | ALGO | 0.999843 | 3.542661 |
664f0f49-e397-4813-be44-cdcddaacc1c2 | C-2024-4-6/240427chenyunxi | 4.2.2.3/4.2.2.3.cpp | #include<iostream>
using namespace std;
void sort(int* a,int n)
{
for (int i = 0; i < n - 1; i++)
{
for (int j = i + 1; j < n; j++)
{
if (a[i] > a[j])
{
int k = 0;
k = a[i];
a[i] = a[j];
a[j] = k;
}
}
}
}
int main()
{
int n;
cout << "ԪظԪأ";
cin >> n;
int* a = new int[n];
for (int ... | ALGO | 0.999447 | 3.293094 |
9d453333-4053-4833-aee2-eb9338f474d3 | Immraannn/DSA1-CPLUS | factorialfunction35.cpp | #include<iostream>
using namespace std;
int factorial(int n){
int prod=1;
for(int i=1;i<=n;i++){
prod *=i;
}
return prod;
}
int ncr(int n,int r){
return factorial(n)/(factorial(n-r)*factorial(r));
}
int main(){
int a,b;
cout<<"Enter the value of a:"<<endl;
cin>>a;
cout<<"Enter the value of b:"<<... | ALGO | 0.998618 | 4.978132 |
6ce0ec61-8b33-44f1-8204-3c4c93d3845b | pmpod/SimpleHeart | RandomGenerator.cpp | #include "RandomGenerator.h"
#include <cmath>
#include <ctime>
#include <cstdlib>
RandomGenerator::RandomGenerator(void)
{
srand( 17 ); //(unsigned) time(0)); //start silnika rand
}
//---------------------------------------------------------------------------
RandomGenerator::~RandomGenerator(void)
{
}
//-------------... | TOOL | 0.91144 | 4.281404 |
38b3b65d-20ed-4e08-b4ab-fb42ba81b6f5 | Seventh-Sense-Artificial-Intelligence/nbis-rs | ext/opencv-4.10.0/samples/cpp/facedetect.cpp | #include "opencv2/objdetect.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/videoio.hpp"
#include <iostream>
using namespace std;
using namespace cv;
static void help(const char** argv)
{
cout << "\nThis program demonstrates the use of cv::CascadeClassifier class to detect obj... | ALGO | 0.856972 | 6.744216 |
3d0085a8-7fc7-4f21-86b0-06eac3f029d1 | angel-hr/hw6 | boggle-driver.cpp | #include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <set>
#include <random>
#include "boggle.h"
using namespace std;
int main(int argc, char* argv[])
{
if(argc < 4)
{
cout << "Usage: boggle-driver <size> <seed> <dictionary file>" << endl;
exit(1);
}
int size = atoi(argv[1]);
... | TOOL | 0.977184 | 5.44684 |
ee78fc94-a187-4244-91ee-553145a1f86e | Dans182/qt-tutorial-beginner | 23-resursividadSerieFibonacci/main.cpp | #include <QCoreApplication>
#include <QDebug>
//la recursividad consiste en una función que se llama así misma
//Acá hacemos la sucesión de fibonacci realizada con recursividad
int fib(int x){
if (x == 0){
return 0;
}
if(x == 1){
return 1;
}
return fib(x - 1) + fib(x - 2);
}
int ma... | ALGO | 0.978755 | 5.041936 |
b0c7b0fd-6254-4e83-96ea-f76700fc9299 | akshaydhame2001/DSAcpp | STL/priorityQ.cpp | #include <bits/stdc++.h>
using namespace std;
void explainPriorityQueue()
{
// Max-Heap (default behavior)
priority_queue<int> maxHeap;
// Insert elements into the max-heap
maxHeap.push(5); // {5}
maxHeap.push(2); // {5, 2}
maxHeap.push(8); // {8, 5, 2}
maxHeap.emplace(10); // ... | ALGO | 0.995294 | 5.385333 |
dbbb9d3b-9ce1-4003-b362-ea7efd832ca4 | hy01er/Codding | algorithm-learning-system/202301/01_auth/004-queue-array.cpp | /* 4.队列
*
* 队列是非常重要的数据结构,生活中也有队列,数据结构中的队列和生活中的类似,用途非常广泛,你可能听说过
* 消息队列,优先级队列,任务队列等等,用途非常广泛,非常非常非常重要!也是一种限制性线性表,和生活中排队
* 一样,存在队头和对尾,队尾进,队头出,存在特性“先进先出”,非常重要的数据结构,而且队列要比栈复杂很多
*/
// 4-2 实现数组形式的队列,更加常见
#include "stdio.h"
#include "stdlib.h"
struct QueueRecord;
typedef struct QueueRecord *Queue;
#define ARR_LENGTH (5... | ALGO | 0.990671 | 3.884726 |
b68e0814-7dad-44f5-ada3-f3671f874d31 | Ypsilonx/AdventOfCode_2024 | Day_06/test_Cplusplus-BAD.cpp | #include <iostream>
#include <vector>
#include <string>
#include <set>
#include <array> // Přidáno pro std::array
#include <fstream>
#include <chrono>
#include <filesystem>
#include <bitset>
#include <unordered_set>
struct State {
int16_t y;
int16_t x;
int8_t dir;
bool operator==(const State& other) ... | ALGO | 0.999896 | 6.483537 |
bbbebe41-1b4c-422a-9512-aaee842824a0 | RolandoAndrade/codesignal | The Core/List Forest Edge/arrayReplace.cpp | vector<int> arrayReplace(vector<int> i, int a, int b)
{
replace(begin(i),end(i),a,b);
return i;
}
| TOOL | 0.977312 | 3.609277 |
a7da384e-fb48-44b9-abbc-bba8d87dd83c | jki14/competitive-programming | 2011/SIM/2-0816-2011 Multi-University Training Contest 8 - Host by HUST/proE.cpp | #include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<climits>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<deque>
#include<set>
using namespace std;
#define maxn 20010
#define clr(x) memset(x,0,sizeof(x));
... | ALGO | 0.999813 | 3.159358 |
aae3f0dd-b1e2-49a4-a660-363bf00f9a91 | hong19891207/carto_release | src/eigen3/bench/benchVecAdd.cpp |
#include <iostream>
#include <Eigen/Core>
#include <bench/BenchTimer.h>
using namespace Eigen;
#ifndef SIZE
#define SIZE 50
#endif
#ifndef REPEAT
#define REPEAT 10000
#endif
typedef float Scalar;
__attribute__ ((noinline)) void benchVec(Scalar* a, Scalar* b, Scalar* c, int size);
__attribute__ ((noinline)) void be... | TOOL | 0.948584 | 5.111393 |
c17c2d1a-2456-4a41-8994-711aba70380a | paul1999/buildhooktest | src/amun/processor/tracking/ballgroundfilter.cpp | #include "ballgroundfilter.h"
#include <QDebug>
// TODO maybe exclude z axis from kalman filter
GroundFilter::GroundFilter(const VisionFrame& frame, CameraInfo* cameraInfo) :
AbstractBallFilter(frame, cameraInfo),
m_lastUpdate(frame.time)
{
Kalman::Vector x(Kalman::Vector::Zero());
x(0) = frame.x;
... | ALGO | 0.978741 | 5.641547 |
151e60e8-75b1-4b44-bdbc-e9bc04f63b95 | AHussain98/CPP | Polymorphism.cpp | #include <iostream>
using namespace std;
#include "Vehicle.cpp"
//polymorphism refers to appearing in many different forms
//this can be done at compile time and runtime
//compile time polymorphism -> function overloading, function overriding, operator overloading
void area(int a, int b){
int ans = a*b;
cout <... | TOOL | 0.91739 | 5.519026 |
35339552-2c82-4af3-a66a-4fb2d878cc57 | 113bommy/deepmind_codecontests_refine | cpp_gold_filter_file/cpp_train_7449_17.cpp | #include <bits/stdc++.h>
using namespace std;
long long int n, p, m, k, x;
long long int a[200005 + 2] = {0};
void solve() {
long long int c = 0;
a[0] = 10000000000;
long long int sexyass = 0;
for (long long int i = 1; i <= n; i++) {
if (a[i] < 0) c++;
if (abs(a[i]) < abs(a[sexyass])) sexyass = i;
}
... | ALGO | 0.999986 | 3.55975 |
d3ff5c78-dba8-436d-8805-c12391a1953c | Fadis/gct | src/gct/generate_projection_matrix.cpp | #include <array>
#include <utility>
#include <glm/ext/matrix_clip_space.hpp>
#include <gct/generate_projection_matrix.hpp>
namespace gct {
std::tuple< float, float > generate_cube_projection_distance(
const glm::vec3 &camera_pos,
const std::vector< aabb > &aabbs
) {
float near = std::numeric_limits< float >::max... | ALGO | 0.996554 | 7.334758 |
0003918e-e2dd-4bcc-a694-ee60a039c7e6 | Zhaoyibinn/LVI-SAM-Study | 相关环境/eigen-3.3.9/bench/sparse_lu.cpp |
// g++ -I.. sparse_lu.cpp -O3 -g0 -I /usr/include/superlu/ -lsuperlu -lgfortran -DSIZE=1000 -DDENSITY=.05 && ./a.out
#define EIGEN_SUPERLU_SUPPORT
#define EIGEN_UMFPACK_SUPPORT
#include <Eigen/Sparse>
#define NOGMM
#define NOMTL
#ifndef SIZE
#define SIZE 10
#endif
#ifndef DENSITY
#define DENSITY 0.01
#endif
#ifnd... | ALGO | 0.989208 | 4.187482 |
31c4a15c-b754-4ea1-9e0c-8929a31cf0fc | MhmmdRifqiAkhdan/AlgoPemrogaman | Tugas2_No2 Algo.cpp | #include<iostream>
using namespace std;
int main(){
string nama;
int tanggal, bulan;
cout<<"Masukkan Nama Anda : ";
cin>>nama;
cout<<"Masukkan Tanggal Lahir Anda : ";
cin>>tanggal;
cout<<"Masukkan Bulan Lahir Anda : ";
cin>>bulan;
cout<<"==============================="<<endl;
if (bulan == 1){
if ((tan... | ALGO | 0.970964 | 3.545306 |
b34b1815-a49d-4f14-b8c6-5ed31f8a9099 | r-abinaya/GFG_Problems | Medium/Rat in a Maze Problem - I/rat-in-a-maze-problem-i.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:
void solve(int row,int col,vector<vector<int>> &m, int n,vector<string> &ans ,string temp ,vector<vector<int>> &visited)
{
... | ALGO | 0.999846 | 6.775548 |
89f4b745-7d7f-4ef9-a5a0-c16062a23afc | raincross7/code-similarity | codes/train_code/problem061/problem061_48.cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
string s;
cin>>s;
int k=0;
long long n;
cin>>n;
long long count=0,a=0,b=0;
while(s[0]==s[k++] && k<=s.length() && s[0]==s[s.length()-1])a++;
k=s.length()-1;
while(s[s.length()-1]==s[k--] && k>=0 &&s[0]==s[s.length()-1])b++;
if(a==s.length(... | ALGO | 0.99994 | 3.805526 |
fb4ea873-4d35-4699-9065-19a6f0de0260 | trannguyenhan/workspace-algorithms | KTLT/lab2/Bai2_11.cpp | #include<bits/stdc++.h>
using namespace std;
typedef complex<double> base;
typedef vector<base> vb;
void input(int &n, int &m, vb &x, vb &y){
cin >> n;
for(int i=0; i<=n; i++){
int tmp;
cin >> tmp;
base mycomplex(tmp,0);
x.push_back(mycomplex);
}
cin >> m;
for(int... | ALGO | 0.999716 | 3.142033 |
35310ab0-1f47-45e7-a3ac-3ea445dbca58 | yoshika-25/CSA0468-Operating-system | Day 3/First Fit.cpp | #include <stdio.h>
#define MEMORY_SIZE 1000
#define BLOCK_SIZE 20
int memory[MEMORY_SIZE];
void initialize_memory() {
int i;
for (i = 0; i < MEMORY_SIZE; i += BLOCK_SIZE) {
memory[i] = BLOCK_SIZE;
}
}
void print_memory() {
int i;
for (i = 0; i < MEMORY_SIZ... | ALGO | 0.981102 | 4.271949 |
8ab89329-0ac3-49f8-ad14-691585fb70b2 | Yuzhou541/Algorithm_competition | 32.food_chain.cpp | #include<iostream>
using namespace std;
const int N = 5e4 + 10;
int p[N], l[N], res;
int find(int x){
if(p[x] != x){
int u = find(p[x]);
l[x] += l[p[x]];
p[x] = u;
}
return p[x];
}
int main()
{
int n, m; cin >> n >> m;
for(int i = 1; i <= n; i++) p[i] = i;
while(m--){
int op, x, y;
cin >> op >> x >> y... | ALGO | 0.999978 | 4.01722 |
a341b6a6-c640-4c94-a80b-64c26d6523b6 | mohamedrady45/Leetcode-solution | 0688-knight-probability-in-chessboard/0688-knight-probability-in-chessboard.cpp | class Solution {
public:
int dx [8] = {-2 , -1 , 1 , 2 , 2, 1,-1,-2};
int dy [8] = {-1 , -2 , -2 , -1 , 1, 2, 2 , 1};
double dp [26][26][101];
static bool valid (int i , int j , int n ){
return i>=0 && i<n && j>=0 && j <n;
}
double solve (int i , int j , int cnt , int n ){
if ... | ALGO | 0.999904 | 4.514897 |
6759d0e6-1d51-4607-a266-f63c78670b66 | HoangNgn30/codeptit | CodePTIT - C++ - basic/CPP0446.cpp | // https://code.ptit.edu.vn/student/question/CPP0446
// TỔNG GẦN 0 NHẤT
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
void TestCase()
{
int n;
cin >> n;
int a[n];
for (auto &x : a) cin >> x;
int res = 2 * 1e6;
for (int i = 0; i + 1 < n; ++i) {
for (int j = i + 1; j < ... | ALGO | 0.999819 | 5.006483 |
a00abfd2-28a6-4467-b64d-6fda5e05fe3d | MintWirapat/diaryfood | 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 |
ff65a110-d506-4211-9c71-930773d7d864 | akbtech17/dsa | Graphs/7 - Problems/15_FindCenterOfGraph.cpp | // 1_FindCenterOfGraph.cpp
// Problem - https://leetcode.com/problems/find-center-of-star-graph/
// Code -
#include<bits/stdc++.h>
using namespace std;
int findCenter(vector<vector<int>> edges) {
// there will be one node common in every edge
// so we sill return the common node of first two edges
return edges[... | ALGO | 0.99983 | 5.605681 |
d77beb88-c889-4764-bc65-ae246194de6f | raspbian-packages/chromium-browser | third_party/skia/src/core/SkMaskBlurFilter.cpp | #include "SkMaskBlurFilter.h"
#include "SkArenaAlloc.h"
#include "SkColorPriv.h"
#include "SkGaussFilter.h"
#include "SkMalloc.h"
#include "SkNx.h"
#include "SkTemplates.h"
#include "SkTo.h"
#include <cmath>
#include <climits>
namespace {
static const double kPi = 3.14159265358979323846264338327950288;
class PlanGa... | TOOL | 0.874226 | 7.446198 |
16cb7864-dbaf-40db-a6a4-6d19aaee9e7d | yjbong/problem-solving | boj/11066/11066.cpp | #include <cstdio>
#define INF 2000000000
int T; // 테스트 케이스
int K; // 소설 장의 수
int a[500]; // 각 장의 크기
int s[500]; // s[i] = a[0]+a[1]+...+a[i]
int d[500][500]; // d[i][j] = a[i]~a[j]를 합치기 위한 최소 비용
int min2(int a, int b){ return a<b?a:b; }
int main(void){
scanf("%d",&T);
while(T--){
scanf("%d",&K);
for(int i=0; i<... | ALGO | 0.99962 | 3.775682 |
f553629b-41b7-4750-81c8-b2ca9317afb6 | Rajsoni03/LeetCode | 61-rotate-list.cpp | // 61. Rotate List
// https://leetcode.com/problems/rotate-list/
/*
Example 1:
Input: head = [1,2,3,4,5], k = 2
Output: [4,5,1,2,3]
Example 2:
Input: head = [0,1,2], k = 4
Output: [2,0,1]
Constraints:
The number of nodes in the list is in the range [0, 500].
-100 <= Node.val <= 100
0 <= k <= 2 * 109
*/
/**
* Defin... | ALGO | 0.999904 | 5.952093 |
b5e781e6-fe9b-4066-9020-cc091e2f2f22 | Ashutosh-0506/Striver-DP | L1AMemoisation.cpp | //***********************************ASHUTOSH KUMAR***********************************//
/*
कर्मण्येवाधिकारस्ते मा फलेषु कदाचन।
मा कर्मफलहेतुर्भूर्मा ते सङ्गोऽस्त्वकर्मणि॥
Karmanye vadhikaraste Ma Phaleshu Kadachana,
Ma Karmaphalaheturbhurma Te Sangostvakarmani,
The meaning of the verse is :—
You have the right to wo... | ALGO | 0.999979 | 5.422307 |
85e1248f-fbc7-48ed-a685-1e3bd4b28fa1 | shriniwasmourya/ACC45DAYSOFCODE-2024 | Day1-Easy-Pronunciation.cpp | #include <iostream>
#include <string>
/*Successfully run Codechef Environment*/
using namespace std;
bool isVowel(char ch) {
return (ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u');
}
bool isEasyToPronounce(const string &s) {
int consonant_count = 0;
for (char ch : s) {
if (isVow... | ALGO | 0.99982 | 6.095759 |
563e1279-f3e0-4f85-9404-6a619f958a67 | codulluiandrei/pbinfo | pbinfo-537/main.cpp | #include <iostream>
#include <fstream>
using namespace std;
ifstream fin("componenteconexe2.in");
ofstream fout("componenteconexe2.out");
int n , a[105][105];
int x[105], // coada pentru parcurgerea in latime
v[105]; // vector caracteristic care precizeaza daca un varf a fost sau nu vizitat
int nrv[105], // numarul de... | ALGO | 0.999416 | 4.430192 |
5d72231c-ffc5-4683-874b-f551ad7f0a03 | AustinBoyuJiang/Competitive-Programming | algo/Others/Divide and Conquer/CDQ/四维偏序.cpp | /*AuthorAustinJiang
Ŀάƫ
ʱ临ӶȣO(n*log(n)^3)
㷨CDQΣ߶ */
#include<bits/stdc++.h>
#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define endl "\n"
#define random(a,b) rand()%(b-a+1)+a
#define PI pair<int,int>
#define VI vector<int>
#define VPI vector... | ALGO | 0.999417 | 3.796362 |
b86642ef-3d6c-49e4-b9f3-583d07feb846 | AarbozT/OpenJDK11.0.8_7-with-OpenJFX11.0.8_2-BUNDLE | src/jdk.pack/share/native/common-unpack/coding.cpp | // -*- C++ -*-
// Small program for unpacking specially compressed Java packages.
// John R. Rose
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include "jni_util.h"
#include "defines.h"
#include "bytes.h"
#include "utils.h"
#include "coding.h"
#include "constants.h"
#include "unpac... | ALGO | 0.998569 | 5.873769 |
e2f188be-a145-44ba-a4fd-331654e07ce5 | aashishanegi/cpp_programs | lc_zz.cpp |
class Solution {
public:
string convert(string s, int numRows) {
if(numRows <= 1) return s;
vector<string>v(numRows, "");
int j = 0, dir = -1;
for(int i = 0; i < s.length(); i++)
{
if(j == numRows - 1 || j == 0) dir *= (-1);
v[j] += s[i];
if(dir == 1) j... | ALGO | 0.999998 | 6.080667 |
cba471db-46c3-4079-aa72-4cb0adf5693a | khushboo-goel/competitive-coding | Arrays/MeetingRooms /easy.cpp | bool compare(vector<int> &a, vector<int> &b) {
return a[0] < b[0];
}
class Solution {
public:
bool canAttendMeetings(vector<vector<int>>& intervals) {
sort(intervals.begin(), intervals.end(), compare);
if (intervals.size() == 0) {
return true;
}
int freeTime = inte... | ALGO | 0.999984 | 6.425827 |
4db59577-3936-416c-a3ba-3733f7d54532 | jenasuman/LeetCode-Solutions | 77-combinations/77-combinations.cpp | class Solution {
public:
vector<vector<int>> ans;
void solve(int index,int n,int k,vector<int>& temp){
if(temp.size()==k){
ans.push_back(temp);
return;
}
for(int i=index;i<=n;i++){
temp.push_back(i);
solve(i+1,n,k,temp);
... | ALGO | 0.99999 | 6.180987 |
aecc197d-d7f4-4d7d-9de9-6c1003f4edf6 | Kenkindom/LeetCode | 143. Reorder List.cpp | //C++ Code
//Title Reorder List
//Difficulty Medium
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class Solution {
public:
void reorderList(ListNode* head) {
ListNode *current = head;
... | ALGO | 0.999999 | 5.986379 |
a1df9b13-9fc5-4065-9aeb-4a97a1aa7510 | mohankarthik/sdcnd | projects/term3/P1-PathPlanning/src/Eigen-3.3/doc/examples/class_VectorBlock.cpp | #include <Eigen/Core>
#include <iostream>
using namespace Eigen;
using namespace std;
template<typename Derived>
Eigen::VectorBlock<Derived>
segmentFromRange(MatrixBase<Derived>& v, int start, int end)
{
return Eigen::VectorBlock<Derived>(v.derived(), start, end-start);
}
template<typename Derived>
const Eigen::Vec... | TOOL | 0.915968 | 4.383477 |
dbebb2aa-1b2e-4493-ae69-c7f5aff2a116 | Kim-Jina/algorithm | Heapsort_Prim/Prim/Prim/main.cpp | #include <iostream>
#include <cstdlib>
using namespace std;
int QisEmpty(int size){ // function which check wheter Queue is empty
if (size == 0) // emtpy
return 1;
else // not empty
return 0;
}
void Min_Heapify(int* Q, int* key, int size, int i){ // Max Heapify
int l = 2 * i + 1, r = 2 * i + 2;... | ALGO | 0.999967 | 3.633659 |
3e85ff4d-4873-496a-9b5a-2ccc74d793ba | JarydMeek/CSCI-2270 | Recitations/Lab4/LinkedList.cpp | #include "LinkedList.h"
using namespace std;
// Add a new node to the list
void LinkedList::insert(Node* prev, int newKey){
//Check if head is Null i.e list is empty
if(head == NULL){
head = new Node;
head->key = newKey;
head->next = NULL;
}
// if list is not empty, look for prev and append our ... | ALGO | 0.999117 | 3.581757 |
60f6cca3-88b7-462d-99dd-9133f45d5948 | Biditmangal/CompetitiveProgramming | CSES ProblemSet/Introductory Problems/TowerOfHanoi.cpp | #include <math.h>
#include <time.h>
#include <ctype.h>
#include <stdio.h>
#include <assert.h>
#include <stdlib.h>
#include <string.h>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
#include <... | ALGO | 0.99956 | 3.9933 |
565afac1-0a6f-4a32-ad32-1409c32ffc0b | Gaurav3009/LeetCode | Determine if Two Trees are Identical - GFG/determine-if-two-trees-are-identical.cpp | //{ Driver Code Starts
#include <bits/stdc++.h>
using namespace std;
struct Node
{
int data;
struct Node *left;
struct Node *right;
Node(int x){
data = x;
left = NULL;
right = NULL;
}
};
// } Driver Code Ends
/* A binary tree node
struct Node
{
int data;
struct No... | ALGO | 0.999565 | 7.454713 |
8f96f217-213f-49c9-875b-f74ed621ec40 | tbulhoes/conference_scheduling | src/model.cpp | #include "model.h"
#include "Data.h"
#include "subProblem.h"
#include "lazyCut.h"
#include "bcModelingLanguageC.hpp"
#include <string>
void buildModel(Data& data, const ApplicationSpecificParam& params, BcModel & model)
{
BcObjectiveArray objective(model);
objective() == 1000*data.getN();
if(params.cut... | ALGO | 0.968336 | 4.775496 |
c346311e-20b0-4fde-afbc-b11a98053776 | luobuyu/Code-test-daily | other/tmpfile/A.cpp | #include <bits/stdc++.h>
#define ll long long
using namespace std;
const int maxn = 30 + 10;
int t;
int a[maxn];
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt", "r", stdin);
#endif // debug
ios::sync_with_stdio(false);
cin.tie(0);
cin >> t;
while (t--)
{
ll ans = 0;
for (in... | ALGO | 0.999038 | 3.659381 |
50b6f16e-d01b-4648-a9da-b336ae74f3b7 | joelind/zxing-iphone | symbian/ZXingBarcodeReader/group/zxing/qrcode/detector/FinderPatternFinder.cpp | #include <zxing/qrcode/detector/FinderPatternFinder.h>
#include <zxing/ReaderException.h>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
namespace zxing {
namespace qrcode {
using namespace std;
class ClosestToAverageComparator {
private:
float averageModuleSize_;
public:
ClosestToAve... | ALGO | 0.999826 | 4.861094 |
58e901fb-5786-4464-9d75-385c52885da8 | thevkp/DSA | String/dominantCharacter.cpp | #include <iostream>
#include <string>
#include <unordered_map>
using namespace std;
char dominantChar(string& str){
unordered_map<char, int> freq;
for(char& ch : str){
freq[ch]++;
}
int maxFreq = 0;
char domChar;
for(auto& it : freq){
if(maxFreq < it.second){
maxFr... | ALGO | 0.999607 | 5.184041 |
5088cba2-0033-4579-a40f-9e9eac527bbb | Kent2256/Leetcode_pactice | C++/278_firstBadversion/Main.cpp | // The API isBadVersion is defined for you.
// bool isBadVersion(int version);
class Solution {
public:
int firstBadVersion(int n) {
if (n==1)return n;
long long int l=1,r=n;
long int mid;
while(l<=r){
long int mid = (l+r)/2;
bool res = isBadVersion(mid);
... | ALGO | 0.999658 | 6.223786 |
a19563ff-9d28-4aa9-ad7b-6983034f8652 | ChoonHean/Kattis | src/installingapps.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;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<double> vd;
typedef... | ALGO | 0.999998 | 3.733611 |
e8b6e82f-1ca7-4adc-949b-67a9b7162276 | yashwani78/DSA | PP/M4/1.Hashing/SubarrayWithGivenSum/myAttempt.cpp | // Given : int arr[n]. Return 'true' if there is a subarray with sum == 0.
#include <iostream>
#include <unordered_map>
using namespace std;
int main(){
int arr[] = {1,2,3,-6};
int n = sizeof(arr)/sizeof(arr[0]);
int psum[n];
psum[0] = arr[0];
for (int i = 1; i < n; i++){
psum[i] = arr[i] +... | ALGO | 0.999588 | 5.371043 |
49815ed3-784c-433a-a8d8-9ed6441a7dab | 7hokerz/bakjoon | bakjoonmoeum(C++)/중요유형(잘 모르는)/트리/트리 DP/2213번(역추적 트리 DP).cpp | #include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <tuple>
using namespace std;
typedef long long ll; typedef pair<int,int> pii; typedef unsigned l... | ALGO | 0.999987 | 4.340092 |
a94d76eb-b75d-4cf6-b043-d4c4c2a37f65 | thanhtu612/Flutter_radiation | counter_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.998865 | 6.785645 |
52d435f3-0baa-4637-aaf1-f6df4191b4fb | Joy-Deb-Nath01/dsa | codechef 1 star/chessrating.cpp | #include<bits/stdc++.h>
using namespace std;
int main()
{
int T;
cin>>T;
for(int i=0;i<T;i++)
{
int x,y;
cin>>x>>y;
int a=y-x;
cout<<ceil(a/8.0)<<endl;
}
} | ALGO | 0.99937 | 3.720474 |
8ae506b8-4324-4bee-aee8-6e62671ee545 | Allen1211/algorithm-problems-solutions | algorithm/KthPrimeNum.cpp | #include <iostream>
using namespace std;
bool isPrime(int n) {
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
int kthPrime(int k) {
int cnt = 0;
for (int i = 2;; i++) {
if (isPrime(i)) {
cnt++;
}
... | ALGO | 0.999828 | 4.911603 |
321c73e7-68c5-4595-a53f-8919f8aee9b7 | ji-bop/Leetcode | C++/calculate.cpp | class Solution {
public:
int calculate(string s) {
stack<int> nums;
int answer = 0;
long long current_val = 0, sign = 1;
for (char c : s) {
if (isdigit(c)) {
current_val = 10 * current_val + c - '0';
} else if (c == '+') {
... | ALGO | 0.999947 | 5.421159 |
f1c3b744-caf5-4c4e-a8f3-4a18a415d27f | kimvjgd/cpp_practice | fastcampus/ex11.cpp | #include <iostream>
using namespace std;
int main()
{
cout << (1 << 3); // 8이 나온다.
}
// 00000001
// 00001000 | ALGO | 0.998609 | 3.153092 |
92883b5f-709d-41ae-8aef-daeca329fad1 | bytedance/terark-zip | 3rdparty/boost-include/libs/algorithm/example/apply_permutation_example.cpp | #include <vector>
#include <iostream>
#include <boost/algorithm/apply_permutation.hpp>
namespace ba = boost::algorithm;
int main ( int /*argc*/, char * /*argv*/ [] )
{
// WARNING: Example require C++11 or newer compiler
{
std::cout << "apply_permutation with iterators:\n";
std::vector<int> ve... | TOOL | 0.994792 | 6.373165 |
db618110-66ed-4636-8fba-94fea1d956b7 | Nyctophiliac1918/cp-core-skills | recursion/binary search (used it in sublime).cpp | #include<iostream>
#include<vector>
#include<string>
#include<climits>
#include<algorithm>
#include<math.h>
#include<map>
using namespace std;
#define ll long long
#define pb push_back
int ser(int *a, int m, int l, int h)
{
if (l > h)
return -1;
int mid = l + (h - l) / 2;
if (a[mid] < m)
r... | ALGO | 0.999016 | 3.156016 |
9f1502dc-4dc0-4252-947c-e1039cd0f3e7 | SeefatHimel/CodeForces | Contests/Codeforces Round #644 (Div. 3)/C.cpp | #include<bits/stdc++.h>
using namespace std;
///Himel_1603062
#define ll long long
#define loop( i,a) for(i=0;i<a;i++)
#define loop1(i,a) for(i=1;i<=a;i++)
#define ppp(a) cout<<a<<endl
#define ssd(a) scanf("%lf",&a)
#define ssi(a) ... | ALGO | 0.999913 | 3.660077 |
d83402b9-252a-42a1-ab15-8a2883d0695b | Palakmalik1594/Learning-to-code-DSA | Difficulty: Easy/Move all negative elements to end/move-all-negative-elements-to-end.cpp | //{ Driver Code Starts
#include <bits/stdc++.h>
using namespace std;
// } Driver Code Ends
class Solution {
public:
void segregateElements(vector<int>& arr) {
int n=arr.size();
vector<int>result;
for(int i=0;i<n;i++){
if(arr[i]>=0){
result.push_back(arr[i]);
... | ALGO | 0.999227 | 5.964579 |
05504341-bc09-42d3-8799-5b28dc6463c6 | SaiVamshiK/Data-Structure-in-C- | Revised DS/Recursion _ Backtracking/Recursion/IMP Generate Permutations.cpp | Given an array nums of distinct integers, return all the possible permutations. You can return the answer in any order.
Example 1:
Input: nums = [1,2,3]
Output: [[1,2,3],[1,3,2],[2,1,3],[2,3,1],[3,1,2],[3,2,1]]
class Solution {
public:
void func(vector<int> &inp,int n,bool *visited,vector<int> &op,vector<vector<... | ALGO | 0.999986 | 5.94492 |
b92e6c98-4e61-42e5-871c-886df68528f7 | chetan-2002/Leetcode-DSA-Questions | 83.remove-duplicates-from-sorted-list.cpp | /*
* @lc app=leetcode id=83 lang=cpp
*
* [83] Remove Duplicates from Sorted List
*/
// @lc code=start
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode() : val(0), next(nullptr) {}
* ListNode(int x) : val(x), next(nullptr) {}
* ListNode(... | ALGO | 0.99993 | 6.246521 |
5b69f6f1-999a-4aac-b10a-a9c3a5d3dbc9 | mgood7123/libmedia | ffmpeg/src/tesseract/wordrec/lm_consistency.cpp | #include "lm_consistency.h"
#include "associate.h"
#include "dict.h"
#include "ratngs.h"
namespace tesseract {
void LMConsistencyInfo::ComputeXheightConsistency(
const BLOB_CHOICE *b, bool is_punc) {
if (xht_decision == XH_INCONSISTENT)
return; // It isn't going to get any better.
// Compute xheight co... | ALGO | 0.937091 | 7.219912 |
0d957b2f-a681-41e6-b481-aa0d9494a1e0 | TUshijima-UCLA/WRR-Experimental-Design-Comparative-Analysis | GA_exp_des/red_solver2.cpp | #include "red_solver.h"
#include "matrix.h"
//#include <time.h>
//#include <chrono>
void red_solver(std::vector<double> &P, std::vector<double> &Ar, std::vector<double> &Br,
std::vector<int> &well, std::vector<double> &wellrate, int &npc, int Nn, int &nq,
std::vector<double> &ts, double &dtmult, std::vector<double> &J... | ALGO | 0.999882 | 3.61723 |
01e8e948-f55d-43eb-a529-f16bd0c5ad39 | shanchi16/SDE-Sheet-challenge- | Day 8/no of coins.cpp | #include<bits/stdc++.h>
using namespace std;
// greedy algo to find min no of coins
using namespace std;
int main() {
int V = 49;
vector < int > ans;
int coins[] = {1, 2, 5, 10, 20, 50, 100, 500, 1000};
int n = 9;
for (int i = n - 1; i >= 0; i--) {
while (V >= coins[i]) {
V -= coins[i];
ans.pu... | ALGO | 0.999888 | 3.641237 |
e55d08af-431f-42e5-b2a7-c45d64efe25c | aswinvisva/optical_flow_algorithms | src/DenseOpticalFlow.cpp | #include <stdio.h>
// #include <io>
#include <opencv2/core.hpp>
#include <opencv2/imgcodecs.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <math.h>
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include <iostream>
#include <stack>
#include <sys/stat.h>
#include <s... | ALGO | 0.998774 | 5.295192 |
d000fc13-37d7-4d66-9a26-7a2fb5ba7d41 | br-labud/cpp | exercises/day_14/Exercise_4.cpp | // Count characters in the string
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <iterator>
using namespace std;
map<char, unsigned> count(const string &string) {
int cnt;
map<char, unsigned> result;
for(int i = 0; i < string.length(); i++) {
cnt = count(string... | ALGO | 0.999245 | 5.416096 |
e525f1a3-aebd-4786-a53a-8eb580750d83 | jerela/cpp-scientific-programming-course-material | assignments/attachments/assignment-function-value-reference-clock.cpp |
/* ASSIGNMENT:
- run the code below
- the code should print how long 1000000 calls of different functions take
1. Which was faster for operating on a character variable, calling by value or calling by reference?
2. How about when operating on a string variable?
3. In the context of the memory sizes the program prints... | TOOL | 0.953346 | 6.264558 |
59636726-00e8-497d-a728-82f8f0f31545 | Shivamkumar26/C_DSA_Codes | 0048-rotate-image/0048-rotate-image.cpp | class Solution {
public:
void rotate(vector<vector<int>>& matrix) {
int n = matrix.size();
for(int i=0; i<n; i++) {
for(int j = 0; j <= i; j++) {
swap(matrix[i][j], matrix[j][i]);
}
}
for(int i=0; i<n; i++) {
for(int j = 0; j < n/... | ALGO | 0.999989 | 6.327645 |
ac4a4fca-ab8b-40dc-983e-74c78f0739f7 | Eileen-Yu/cheatsheet | stack/remove-all-adjacent-duplicates-in-string-II.cpp | // https://leetcode.com/problems/remove-all-adjacent-duplicates-in-string-ii
//
class Solution {
public:
string removeDuplicates(string s, int k) {
int n = s.size();
if (n < k)
return s;
stack<pair<char, int>> stk;
for (int i = 0; i < n; ++i) {
if (stk.empty() || stk.top().first != s[i])
... | ALGO | 0.999547 | 6.906707 |
76b9e523-45ff-41aa-9d3c-b4abac24cab2 | POC-2025/leetcode | solution/2900-2999/2944.Minimum Number of Coins for Fruits/Solution.cpp | class Solution {
public:
int minimumCoins(vector<int>& prices) {
int n = prices.size();
int f[n + 1];
memset(f, 0x3f, sizeof(f));
function<int(int)> dfs = [&](int i) {
if (i * 2 >= n) {
return prices[i - 1];
}
if (f[i] == 0x3f3f3f3f... | ALGO | 0.999806 | 5.874708 |
7d82c5ca-51bd-4ccd-a7c7-9acabd7a799e | wisdompeak/LeetCode | Deque/2398.Maximum-Number-of-Robots-Within-Budget/2398.Maximum-Number-of-Robots-Within-Budget_v3.cpp | using LL = long long;
class Solution {
public:
int maximumRobots(vector<int>& chargeTimes, vector<int>& runningCosts, long long budget)
{
vector<pair<LL,LL>>robots;
int n = chargeTimes.size();
LL left = 0, right = n;
while (left < right)
{
LL mid = r... | ALGO | 0.999965 | 5.481004 |
058656da-0e16-499d-bb24-e19d89eb5df0 | 306470558/mb | third_party/skia/tools/skdiff_image.cpp | #include "skdiff.h"
#include "skdiff_utils.h"
#include "SkBitmap.h"
#include "SkData.h"
#include "SkImageDecoder.h"
#include "SkImageEncoder.h"
#include "SkOSFile.h"
#include "SkTDArray.h"
#include "SkTemplates.h"
#include "SkTypes.h"
#include <stdio.h>
/// If outputDir.isEmpty(), don't write out diff files.
static v... | TOOL | 0.914806 | 7.024352 |
d787dddd-4740-469f-83ce-4acccd080a59 | linkeLi0421/llvm-project15-IRDumperPass | libc/src/math/generic/modf.cpp | #include "src/math/modf.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "src/__support/common.h"
namespace __llvm_libc {
LLVM_LIBC_FUNCTION(double, modf, (double x, double *iptr)) {
return fputil::modf(x, *iptr);
}
} // namespace __llvm_libc
| ALGO | 0.985847 | 6.863791 |
ee9607a3-8b26-4e0a-bfc5-4c3ef791fc24 | mtresearcher/moses-online | mert/TER/hashMap.cpp | #include "hashMap.h"
// The following class defines a hash function for strings
using namespace std;
namespace HashMapSpace
{
// hashMap::hashMap();
/* hashMap::~hashMap()
{
// vector<stringHasher>::const_iterator del = m_hasher.begin();
for ( vector<stringHasher>::const_iterator del=m_hasher.... | TOOL | 0.913263 | 4.080107 |
03b23ad7-6560-4752-a7e4-21b3f316f8cb | gtkn/atcoder | ABC_249_D_2.cpp | //title
#include <bits/stdc++.h>
using namespace std;
//#include <atcoder/all>
//using namespace atcoder;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define rep1(i,n) for (ll i = 1; i <= (n); ++i)
#define repr(i,n) for (ll i = (n)-1; i >= 0; --i)
#define rep1r(i,n) for (ll i = (n); i > 0; --i)
#define bit(n,k) ((n>>... | ALGO | 0.99986 | 4.132891 |
f63c88e4-61d0-471a-ab11-3d0e363bd599 | SouravBarman001/Data-structure-and-algorithm-in-cpp | Array/Record_breaking_day.cpp | #include<iostream>
using namespace std;
int main(){
int n;
cin>>n;
int arr[n];
for(int i=0; i<n; i++){
cin>>arr[i];
}
// int a = arr[0];
// int b = arr[1];
int temp = arr[1];
for(int i=0; i < n ; i++){
if (arr[i] > temp)
{
temp = arr[i];
}if(ar... | ALGO | 0.999726 | 3.253955 |
c2e3f63b-14d7-49cd-a4c4-a2a9029f6ebd | Pyrodox/CPP_Projects | algorithms/buildgates.cpp | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mx = 1002;
ll n, x = 0, y = 0, ans = 0;
vector<vector<bool>> vis(2 * mx, vector<bool>(2 * mx)), fencednew(2 * mx, vector<bool>(2 * mx));
vector<vector<ll>> grid;
vector<pair<ll, ll>> fenced;
bool flag = true;
void move(char c)
{
if (c =... | ALGO | 0.999945 | 4.088718 |
5715571b-d0ea-4218-b3a6-dde4259477bb | 6Akos9/CPP2023 | lab03/List.cpp | //
// Created by balaz on 2023. 10. 11..
//
#include <stdexcept>
#include <iostream>
#include "List.h"
using namespace std;
List::List() {
first = nullptr;
}
List::~List() {
while(first != nullptr) {
Node* tmp = first;
first = first->next;
delete tmp;
}
}
bool List::exists(int d)... | ALGO | 0.956039 | 4.089102 |
89d35059-83ce-4c25-a003-f7479acba56d | minhphuc477/DSA12 | DSA12/test 8 for DSA111 test.cpp | //#include <iostream>
//#include <cstdlib>
//#include <string>
//#include <sstream>
//#include <algorithm>
//#include <queue>
//#include<stack>
//
//using namespace std;
//
//const int MAX_SIZE = 100;
//// Array class
//class Array {
//private:
// int arr[MAX_SIZE];
// int size;
//
//public:
// Array() : arr{}... | ALGO | 0.996204 | 5.022143 |
892b2c67-3265-4f4b-96f8-b4c2670c433c | piyush-112/CDAC | C++ Programs/FindAvgOfSub.cpp | //Wap to find the average of the three subject upto 2 decimal places;
#include<iostream>
using namespace std;
int main(){
int s1,s2,s3,total;
float avg;
cout<<"Enter the marks of sub s1,s2,s3:";
cin>>s1>>s2>>s3;
total=s1+s2+s3;
cout<<"The total of the subject:"<<total;
avg=total/3;
cout<<"\nThe average of the ... | ALGO | 0.961625 | 3.223381 |
0c024cef-2ed1-45c6-a0ff-b3b5d3813892 | TrifanBogdan24/Probleme-PBINFO | pbinfo/coduri-cpp/clasa-IX/minicalc_ifs.cpp | // #450 - minicalc
#include <iostream>
using namespace std;
int main()
{
int a = 0, b = 0, c = 0;
cin >> a >> b >> c;
if (c == 1) cout << (a + b);
else if (c == 2) cout << (a - b);
else if (c == 3) cout << (a * b);
else if (c == 4) cout << (a / b);
else if (c == 5) cout << (a % b);
... | ALGO | 0.999846 | 4.203351 |
5a967841-28de-41ef-b6d1-7d13aa12b522 | ErAnirudha/c-plus-plus-prog | ElectricityBill.cpp | #include<iostream>
using namespace std;
int main(){
float units;
string consumerName,MeterNo;
cout<<"\nEnter consumer name:= ";
getline(cin, consumerName);
cout<<"\nEnter MeterNo := ";
getline(cin, MeterNo);
cout<<"\nEnter No of Units consumed this Month:= ";
cin>>units;
cout<<"\nNO of units consumed ... | TOOL | 0.961458 | 3.811592 |
86f2ff5e-f2ad-4a86-84f4-eb90893790a0 | yzcmf/Interview | LeetCode-Solutions/C++/maxProfitII.cpp | // Time Complexity: O(n)
// Space Complexity: O(1)
class Solution {
public:
int maxProfit(vector<int> &prices) {
const int n = prices.size();
int ans = 0;
for(int i = 1; i < n; ++i) {
int diff = prices[i] - prices[i - 1];
if(diff > 0)
... | ALGO | 0.999688 | 6.083575 |
b87871df-d316-403d-9b35-3dbdac19c3fc | David0E28/od | 分披萨.cpp | /*
题目描述
"吃货"和"馋嘴"两人到披萨店点了一份铁盘(圆形)披萨,并嘱咐店员将披萨按放射状切成大小相同的偶数个小块。但是粗心的服务员将披萨切成了每块大小都完全不同奇数块,且肉眼能分辨出大小。
由于两人都想吃到最多的披萨,他们商量了一个他们认为公平的分法:从"吃货"开始,轮流取披萨。除了第一块披萨可以任意选取外,其他都必须从缺口开始选。
他俩选披萨的思路不同。"馋嘴"每次都会选最大块的披萨,而且"吃货"知道"馋嘴"的想法。
已知披萨小块的数量以及每块的大小,求"吃货"能分得的最大的披萨大小的总和。
输入描述
第 1 行为一个正整数奇数 N,表示披萨小块数量。
3 ≤ N < 500
接下来的第 2 行到第 N + 1 ... | ALGO | 0.999966 | 4.483984 |
f3685044-d17f-487b-9543-931f880fd109 | ishandutta2007/codeforces | tfg/normal/1423/B.cpp | #include <bits/stdc++.h>
using namespace std;
bool dfs(int a, int L, vector<vector<int>>& g, vector<int>& btoa, vector<int>& A, vector<int>& B) {
if (A[a] != L) return 0;
A[a] = -1;
for (auto &b: g[a]) if (B[b] == L + 1) {
B[b] = 0;
if (btoa[b] == -1 || dfs(btoa[b], L + 1, g, btoa, A, B))
return btoa[b] = a,... | ALGO | 0.999947 | 4.585155 |
0d8ffc4f-1e11-4824-8010-95b2d25be7a7 | Oye7z/Daily_LeetCode | 226_invertTree.cpp | /**
* Definition for a binary tree node.
* struct TreeNode {
* int val;
* TreeNode *left;
* TreeNode *right;
* TreeNode(int x) : val(x), left(NULL), right(NULL) {}
* };
*/
class Solution {
public:
TreeNode* invertTree(TreeNode* root) {
preorderTraversal(root);
return root;
... | ALGO | 0.99999 | 6.256784 |
ad8b64d9-9d9e-47ac-8795-4846554b57b0 | raincross7/code-similarity | codes/train_code/problem427/problem427_131.cpp | #include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
using ll = long long;
using graph = std::vector<std::vector<ll>>;
using namespace std;
int main() {
ll N,M,V,P;
cin >> N >> M >> V >> P;
vector<ll> A(N);
vector<ll> B(N + 1);
... | ALGO | 0.999984 | 3.719832 |
32137a4a-3e10-40d3-a0bc-f66d6ac16807 | Mohammed-Ebrahim-Ahmed/ENG_eltawel_CPP | Eltawel_assignments/session4/assignment_3.cpp | #include <iostream>
#include <vector>
#include <algorithm>
class Book {
public:
Book(std::string t, std::string a, int y): title{t}, author{a},year{y}{}
std::string GetTitle(){return title;}
std::string GetAuthor(){return author;}
int GetYear(){return year;}
void displayInfo(... | TOOL | 0.982774 | 5.174479 |
5c5ac61f-0109-476e-9932-da9f1f84d88e | KangHuiSoo/repo | flutter/bloc_state_practice1/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.998524 | 6.785645 |
65b9d5e3-5c8c-4ac1-afff-33ef70be5542 | fitnesswithrohit/Chitkara-OOPs | CODE/Leetcode/reverse_string_344.cpp | #include <bits/stdc++.h>
using namespace std;
void reverseString(vector<char> &s)
{
int i = 0, j = s.size() - 1;
while (i < j)
{
swap(s[i], s[j]);
i++;
j--;
}
}
int main()
{
int n;
cin>>n;
vector<char>s(n);
for(int i=0;i<n;i++){
cin>>s[i];
}
rev... | ALGO | 0.999952 | 4.753795 |
782fdc46-f337-446d-a046-57c8c1ef6072 | MariaMayy/LeetCode | Implement_queue_using_stacks.cpp | class MyQueue {
public:
/** Initialize your data structure here. */
stack<int> del;
stack<int> add;
MyQueue() {
stack<int> del;
stack<int> add;
}
/** Push element x to the back of queue. */
void push(int x) {
add.push(x);
}
/** Removes the element fr... | ALGO | 0.998408 | 5.693776 |
75308225-413a-466f-961b-bb8c9b593263 | jigjnasu/leet_code | 461_hamming_distance.cpp | /*
LeetCode.com
Problem No: 461
Problem: Hamming Distancd
Rakesh Kumar @ <EMAIL>
Date: Nov 28th, 2016
*/
#include <cstdio>
#include <cmath>
class Solution {
public:
int hammingDistance(int x, int y) {
int t = x ^ y;
int r = 0;
while (t > 0) {
r+= t & 1;
t... | ALGO | 0.999956 | 5.601803 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.