text
stringlengths
183
150k
path
stringlengths
15
112
bucket
stringclasses
4 values
source
stringclasses
14 values
group
stringclasses
121 values
spdx
stringclasses
11 values
repo_license
stringclasses
11 values
commit
stringclasses
13 values
lang
stringclasses
4 values
def_heavy
bool
1 class
comment_ratio
float64
0
1
restricted
bool
2 classes
fresh
bool
1 class
n_bytes
int64
183
150k
n_tokens
int64
-1
-1
/** * @file union_find.c * @brief [Union * find](https://en.wikipedia.org/wiki/Disjoint-set_data_structure) algorithm. */ #include <stdio.h> #include <stdlib.h> #define MAX_SIZE 1000 /**< maximum number of elements in the set */ /** * @brief Find index of or value in an array * * @param [in,out] p array to sear...
thealgorithms-c/misc/union_find.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.35
false
false
1,968
-1
#include <stdio.h> #include <stdlib.h> // Function for Tower of Hanoi algorithm void hanoi(int noOfDisks, char where, char to, char extra) { if (noOfDisks != 0) { hanoi(noOfDisks - 1, where, extra, to); printf("Move disk : %d from %c to %c\n", noOfDisks, where, to); hanoi(noOfDisks - 1...
thealgorithms-c/misc/tower_of_hanoi.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.19
false
false
550
-1
// Sorting of array list using cycle sort #include <stdio.h> #include <stdlib.h> // Displays the array, passed to this method void display(int *arr, int n) { int i; for (i = 0; i < n; i++) { printf("%d ", arr[i]); } printf("\n"); } // Swap function to swap two values void swap(int *first,...
thealgorithms-c/sorting/cycle_sort.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.25
false
false
2,453
-1
#include <limits.h> /// for INT_MIN #include <stdio.h> /// for IO operations #include <stdlib.h> /// for dynamic memory allocation typedef struct max_heap { int *p; int size; int count; } Heap; Heap *create_heap(Heap *heap); /*Creates a max_heap structure and returns a ...
thealgorithms-c/data_structures/heap/max_heap.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/heap
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.084
false
false
4,068
-1
// Forward declaration of isBadVersion API. bool isBadVersion(int version); int firstBadVersion(int n) { int low = 1, high = n; while (low <= high) { int mid = low + (high - low) / 2; if (isBadVersion(mid)) { high = mid - 1; } else { l...
thealgorithms-c/leetcode/src/278.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.053
false
false
368
-1
/* author: Christian Bender This is the implementation of the (generic) stack. The implementation uses the dynamic memory management and the principle of data hiding. */ #include <assert.h> #include <stdio.h> #include <stdlib.h> #include "stack.h" /* actual stack data structure This pointer wi...
thealgorithms-c/data_structures/stack/stack.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/stack
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.343
false
false
2,578
-1
#include <stdio.h> #include <stdlib.h> #define MAX_SIZE 40 // Assume 40 nodes at max in graph #define INT_MIN 0 // A vertex of the graph struct node { int vertex; struct node *next; }; // Some declarations struct node *createNode(int v); struct Graph { int numVertices; int *visited; struct node * ...
thealgorithms-c/data_structures/graphs/topological_sort.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/graphs
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.139
false
false
4,552
-1
/** * \file * \brief [Problem 3](https://projecteuler.net/problem=3) solution * * Problem: * * The prime factors of 13195 are 5,7,13 and 29. What is the largest prime * factor of a given number N? e.g. for 10, largest prime factor = 5. For 17, * largest prime factor = 17. */ #include <stdio.h> /** Main functi...
thealgorithms-c/project_euler/problem_3/sol2.c
algorithms
thealgorithms-c
thealgorithms-c/project_euler/problem_3
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.375
false
false
626
-1
#include <stdio.h> #include <stdlib.h> #include <string.h> char *to_rna(const char s[]) { /* determines the length of the given string */ int len = strlen(s); /* creates a return string */ char *ans = malloc(sizeof(char) * len); /* for the loop */ int i = 0; /* actual compile process */ ...
thealgorithms-c/exercism/rna_transcription/rna_transcription.c
algorithms
thealgorithms-c
thealgorithms-c/exercism/rna_transcription
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.219
false
false
674
-1
/** * @file * \brief Compute real eigen values and eigen vectors of a symmetric matrix * using [QR decomposition](https://en.wikipedia.org/wiki/QR_decomposition) * method. * \author [Krishna Vedala](https://github.com/kvedala) */ #include <assert.h> #include <math.h> #include <stdio.h> #include <stdlib.h> #includ...
thealgorithms-c/numerical_methods/qr_eigen_values.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.295
false
false
9,970
-1
#include <limits.h> #include <stdio.h> #include <stdlib.h> #include <string.h> // Structure for storing a graph struct Graph { int vertexNum; int **edges; }; // Constructs a graph with V vertices and E edges void createGraph(struct Graph *G, int V) { G->vertexNum = V; G->edges = (int **)malloc(V * siz...
thealgorithms-c/data_structures/graphs/dijkstra.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/graphs
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.152
false
false
2,961
-1
/* Includes the functions for Recursive Traversals of a Binary Tree. It is assumed that nodes and tree have been created as per create_node.c */ #include <stdio.h> void inOrderTraversal(struct node *node) { if (node == NULL) // if tree is empty return; inOrderTraversal(node->leftNode); pr...
thealgorithms-c/data_structures/binary_trees/recursive_traversals.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/binary_trees
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.139
false
false
975
-1
char *reverseOnlyLetters(char *S) { int last = strlen(S) - 1, i; for (i = 0; i < last;) { if (!isalpha(S[i])) { i++; continue; } if (!isalpha(S[last])) { last--; continue; } char tmp = S[i]; S[i] ...
thealgorithms-c/leetcode/src/917.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0
false
false
405
-1
/** * @file * @brief [Linear Search with Sentinel](https://en.wikipedia.org/wiki/Linear_search#With_a_sentinel) algorithm implementation * @details * This algorithm saves the last element of the array, * then replaces it with the value to be found and sets it as the sentinel. * When searching, compares each ele...
thealgorithms-c/searching/sentinel_linear_search.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.609
false
false
2,836
-1
//////////////////////////////////////////////////////////////////////////////// // INCLUDES #include "include.h"; //////////////////////////////////////////////////////////////////////////////// // GLOBAL VARIABLES int count; //////////////////////////////////////////////////////////////////////////////// // MAIN EN...
thealgorithms-c/data_structures/queue/queue.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/queue
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.246
false
false
1,311
-1
/** * @file * \brief This file is a simple implementation of a Threaded Binary Tree * * Threaded Binary Tree is a binary tree variant in which all left child * pointers that are NULL (in Linked list representation) point to its * in-order predecessor, and all right child pointers that are NULL * (in Linked list ...
thealgorithms-c/data_structures/binary_trees/threaded_binary_trees.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/binary_trees
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.219
false
false
6,982
-1
int getPointKey(int i, int j, int boardSize, int boardColSize){ return boardSize * boardColSize * i + j; } const int directionsSize = 4; const int directions[4][2] = {{-1, 0}, {1, 0}, {0, -1}, {0, 1}}; bool exitsWord(int i, int j, char** board, int boardSize, int* boardColSize, int wordIndex, char* word, int* vis...
thealgorithms-c/leetcode/src/79.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.043
false
false
1,823
-1
/** * @file * @brief Program to identify if a number is [palindrome * number](https://en.wikipedia.org/wiki/Palindrome) or not. * @see project_euler/problem_4/sol1.c */ #include <assert.h> #include <stdbool.h> #include <stdio.h> bool isPalindrome(int number); /** Driver Code */ int main() { assert(isPalindro...
thealgorithms-c/math/palindrome.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.432
false
false
943
-1
#include <stdio.h> #include <stdlib.h> void sort(int *numbers, int size) { int pos = 0; while (pos < size) { if (numbers[pos] >= numbers[pos - 1]) pos++; else { int tmp = numbers[pos - 1]; numbers[pos - 1] = numbers[pos]; numbers[pos] ...
thealgorithms-c/sorting/gnome_sort.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.049
false
false
911
-1
#include <stdio.h> #include <stdlib.h> void pigeonholeSort(int arr[], int size) { int i, j, min = arr[0], max = arr[0], range; // Getting range of the array using max and min for (i = 1; i < size; i++) { if (arr[i] < min) min = arr[i]; if (arr[i] > max) max = ar...
thealgorithms-c/sorting/pigeonhole_sort.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.079
false
false
1,387
-1
/** * @file * @brief [Postfix evaluation algorithm](https://www.includehelp.com/c/evaluation-of-postfix-expressions-using-stack-with-c-program.aspx) implementation * @details * The input postfix expression is of type string upto 49 characters (including space delimiters). * Supported operations- '+', '-', '/', '*'...
thealgorithms-c/misc/postfix_evaluation.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.355
false
false
2,963
-1
/** * @file * @brief [Bubble sort](https://en.wikipedia.org/wiki/Bubble_sort) algorithm * implementation */ #include <assert.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <time.h> /** * Display elements of array * @param arr array to be display * @param n length of array */ void displ...
thealgorithms-c/sorting/bubble_sort.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.393
false
false
2,192
-1
/** * \file * \brief [LU decomposition](https://en.wikipedia.org/wiki/LU_decompositon) of a * square matrix * \author [Krishna Vedala](https://github.com/kvedala) */ #include <stdio.h> #include <stdlib.h> #include <time.h> #ifdef _OPENMP #include <omp.h> #endif /** Perform LU decomposition on matrix * \param[in]...
thealgorithms-c/numerical_methods/lu_decompose.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.336
false
false
3,163
-1
// Breadth-first search, imitation. // Runtime: O(n) // Space: O(n) int jump(int* nums, int numsSize) { if (numsSize == 1) { return 0; } int step = 1; int* visitedCells = calloc(numsSize, sizeof(int)); int* queue = malloc(numsSize * sizeof(int)); queue[0] = 0; int queueLength = 1; ...
thealgorithms-c/leetcode/src/45.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.098
false
false
1,249
-1
/** * @file * @brief An [affine cipher](https://en.wikipedia.org/wiki/Affine_cipher) is a * letter substitution cipher that uses a linear transformation to substitute * letters in a message. * @details Given an alphabet of length M with characters with numeric values * 0-(M-1), an arbitrary character x can be tra...
thealgorithms-c/cipher/affine.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.463
false
false
4,969
-1
/* programme for computing number of zeroes at the end of factorial of a given number n */ #include <math.h> //including math.h header file to use pow function #include <stdio.h> int main() { int i, n, test = 0, count = 0; // taking input number n scanf("%d", &n); // looping from 1 till loop break ...
thealgorithms-c/math/factorial_trailing_zeroes.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.207
false
false
745
-1
/* code for computing nth catalan number */ #include <stdio.h> long int factorial(int x) // long int for more than 10 factorial { int i; long int fac; // fac stores x factorial fac = x; for (i = 1; i < x; i++) // loop to calculate x factorial { fac = fac * (x - i); } return fac; ...
thealgorithms-c/math/catalan.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.107
false
false
679
-1
/** * \file * \brief [Problem 23](https://projecteuler.net/problem=23) solution - * optimization using look-up array * \author [Krishna Vedala](https://github.com/kvedala) * * Optimization applied - compute & store abundant numbers once * into a look-up array. */ #include <stdio.h> #include <stdlib.h> #include ...
thealgorithms-c/project_euler/problem_23/sol2.c
algorithms
thealgorithms-c
thealgorithms-c/project_euler/problem_23
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.414
false
false
4,856
-1
/* Program to demonstrate non recursive merge sort */ /* Merge sort is an effective sorting algorithm which falls under divide and conquer paradigm and produces a stable sort. Merge sort repeatedly breaks down a list into several sublists until each sublist consists of a single element and merging those sublists in a ...
thealgorithms-c/sorting/merge_sort_nr.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.089
false
false
2,296
-1
struct ListNode *getIntersectionNode(struct ListNode *headA, struct ListNode *headB) { struct ListNode *cur1 = headA, *cur2 = headB; if (cur1 == NULL || cur2 == NULL) return NULL; while (cur1 && cur2 && cur1 != cur2) { cur1 = cur1->next; cur2 ...
thealgorithms-c/leetcode/src/160.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0
false
false
500
-1
int peakIndexInMountainArray(int *A, int ASize) { int low = 1, high = ASize; while (low <= high) { int mid = low + (high - low) / 2; if (A[mid - 1] < A[mid] && A[mid] > A[mid + 1]) return mid; else if (A[mid - 1] < A[mid] && A[mid] < A[mid + 1]) low = mid + 1;...
thealgorithms-c/leetcode/src/852.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0
false
false
385
-1
/** * @file * @author [NVombat](https://github.com/NVombat) * @brief Client-side implementation of [Remote Command * Execution Using * UDP](https://www.imperva.com/learn/ddos/udp-user-datagram-protocol/) * @see remote_command_exec_udp_server.c * * @details * The algorithm is based on the simple UDP client and ...
thealgorithms-c/client_server/remote_command_exec_udp_client.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.722
false
false
5,897
-1
#include <math.h> #include <stdio.h> float f(float x) { return 1.0 + x * x * x; // This is the expresion of the function to integrate? } int main() { int i, n; float a, b, h, x, s2, s3, sum, integral; printf("enter the lower limit of the integration:"); scanf("%f", &a); printf("en...
thealgorithms-c/numerical_methods/simpsons_1_3rd_rule.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.059
false
false
836
-1
// Given a string s, returns the number of segments in the string. int countSegments(char * s){ int sLen = strlen(s); int prevSpace = 1; int result = 0; char currChar; for (int i = 0; i < sLen; i++){ currChar = s[i]; //A string of whitespaces will only be counted once as the condit...
thealgorithms-c/leetcode/src/434.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.176
false
false
650
-1
struct ListNode *detectCycle(struct ListNode *head) { if (head == NULL || head->next == NULL) return NULL; struct ListNode *slow, *fast; slow = fast = head; while (fast && fast->next) { slow = slow->next; fast = fast->next->next; if (slow == fast) { ...
thealgorithms-c/leetcode/src/142.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0
false
false
548
-1
/** * @file * @brief [McNaughton–Yamada–Thompson algorithm](https://en.wikipedia.org/wiki/Thompson%27s_construction) * @details * From Wikipedia: * In computer science, Thompson's construction algorithm, * also called the McNaughton–Yamada–Thompson algorithm, * is a method of transforming a regular expression in...
thealgorithms-c/misc/mcnaughton_yamada_thompson.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.369
false
false
21,687
-1
/** * @file * @brief File used to test min_printf function. * @details * The test will be executed by comparing the result of both `min_printf` and `printf` functions * @author [Jaskarn7](https://github.com/Jaskarn7) * @see min_printf.h */ #include "min_printf.h" /// for `min_printf` function #include <stdio.h> ...
thealgorithms-c/developer_tools/test_min_printf.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.686
false
false
1,610
-1
int hammingDistance(int x, int y) { int difference = x ^ y; // The XOR operator generates the bitwise difference in the // binary representation of two numbers If bit in ith position // of both numbers is same, bit in difference is 0, otherwise 1 int TotalBits = sizeof(d...
thealgorithms-c/leetcode/src/461.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.25
false
false
841
-1
/** * @file * @brief [Secant Method](https://en.wikipedia.org/wiki/Secant_method) implementation. Find a * continuous function's root by using a succession of roots of secant lines to * approximate it, starting from the given points' secant line. * @author [Samuel Pires](https://github.com/disnoca) */ #include <...
thealgorithms-c/numerical_methods/secant_method.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.565
false
false
2,373
-1
#include <stdbool.h> #include <stdio.h> #include "Graph.h" #define MAX_NODES 1000 bool visited[MAX_NODES]; bool hamiltonR(Graph g, int nV, Vertex v, Vertex dest, int d) { // v = current vertex considered // dest = destination vertex // d = distance "remaining" until path found Vertex w; if (v ==...
thealgorithms-c/data_structures/graphs/hamiltonian.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/graphs
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.322
false
false
3,077
-1
#include <stdio.h> #include <stdlib.h> #include "dynamic_array.h" int main() { dynamic_array_t *da = init_dynamic_array(); for (int i = 1; i <= 50; i++) { add(da, &i); } delete (da, 10); int value = 1000; put(da, &value, 0); value = 5000; int another_value = 7000; ...
thealgorithms-c/data_structures/dynamic_array/main.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/dynamic_array
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.125
false
false
550
-1
/* Queue using Linked List - Program to create a queue ADT using linked list. ADT should support the following operations 1) Createqueue 2) Insert into the queue 3) Delete from the queue 4) destroyqueue */ /* queue q declared globally */ #include <stdio.h> #include <stdlib.h> #define NULL 0 struct node { int...
thealgorithms-c/data_structures/linked_list/queue_linked_list.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/linked_list
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.07
false
false
2,487
-1
// Window sliding. Runtime: O(n), Space: O(n) int maximumUniqueSubarray(int* nums, int numsSize){ short* numsSet = (short*)calloc(10001, sizeof(short)); numsSet[nums[0]] = 1; int maxSum = nums[0]; int windowSumm = maxSum; int leftIndex = 0; int num = 0; for(int i = 1; i < numsSize; i+...
thealgorithms-c/leetcode/src/1695.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.043
false
false
686
-1
/** * @file * * @brief * Dynamic [Stack](https://en.wikipedia.org/wiki/Stack_(abstract_data_type)), * just like Dynamic Array, is a stack data structure whose the length or * capacity (maximum number of elements that can be stored) increases or * decreases in real time based on the operations (like insertion or ...
thealgorithms-c/data_structures/stack/dynamic_stack.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/stack
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.402
false
false
6,537
-1
#include <stdio.h> int main() { int a[200], n, counter, temp, i; a[0] = 1; counter = 0; printf("Enter a whole number to Find its Factorial: "); scanf("%d", &n); if (n < 0) printf("Cannot Calculate factorials for negative numbers."); else { for (; n >= 2; n--) { ...
thealgorithms-c/math/factorial.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.032
false
false
745
-1
/* > Counting sort is a sorting technique based on keys between a specific range. > integer sorting algorithm > Worst-case performance O(n+k) > Stabilized by prefix sum array */ #include <stdio.h> #include <stdlib.h> #include <string.h> int main() { int i, n, l = 0; printf("Enter size of array = "); ...
thealgorithms-c/sorting/counting_sort.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.125
false
false
1,057
-1
#include <stdio.h> #include <stdlib.h> typedef struct min_heap { int *p; int size; int count; } Heap; Heap *create_heap(Heap *heap); /*Creates a min_heap structure and returns a pointer to the struct*/ void down_heapify(Heap *heap, int index); /*Pushes an element downward...
thealgorithms-c/data_structures/heap/min_heap.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/heap
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.077
false
false
3,972
-1
int max(a,b){ if(a>b) return a; else return b; } int findMaxConsecutiveOnes(int* nums, int numsSize){ int count = 0; int result = 0; for (int i = 0; i < numsSize; i++) { if (nums[i] == 0) count = 0; else { count++; result = max(result, count); } } return r...
thealgorithms-c/leetcode/src/485.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0
false
false
329
-1
/** * @file * @brief Strong number is a number whose sum of all digits’ factorial is equal * to the number n For example: 145 = 1!(1) + 4!(24) + 5!(120) */ #include <assert.h> #include <stdbool.h> #include <stdio.h> /** * Check if given number is strong number or not * @param number * @return `true` if given nu...
thealgorithms-c/math/strong_number.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.415
false
false
1,114
-1
const int EnglishLettersNumber = 26; void countCharsForStringSlice(int* charsCounter, char* s, int length, int sign) { for (int i = 0; i < length; i++) { charsCounter[s[i] - 'a'] += sign; } } // Sliding window // Calculate number of chars in the current slide. // Runtime: O(n) // Space: O(1) - only ...
thealgorithms-c/leetcode/src/567.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.094
false
false
1,716
-1
#define max(a,b) (((a)>(b))?(a):(b)) int longestSquareStreakDp(int* numsSet, int numsSetSize, int* dp, long num){ if (dp[num] != 0){ return dp[num]; } long numSquare = num * num; dp[num] = 1; if (numSquare <= numsSetSize && numsSet[numSquare] == 1){ dp[num] += longestSquareStreakD...
thealgorithms-c/leetcode/src/2501.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.171
false
false
1,241
-1
#include <stdbool.h> #include <stdio.h> #define NODES 4 int digraph[NODES][NODES] = { {0, 1, 1, 1}, {1, 0, 1, 0}, {0, 1, 0, 0}, {0, 0, 0, 0}}; int tc[NODES][NODES]; void warshall() { int i, s, t; for (s = 0; s < NODES; s++) for (t = 0; t < NODES; t++) tc[s][t] = digraph[s][t]; for (i = 0; i ...
thealgorithms-c/data_structures/graphs/transitive_closure.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/graphs
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.472
false
false
2,144
-1
/** * \file * \brief [Problem 1](https://projecteuler.net/problem=1) solution * * An Efficient code to print all the sum of all numbers that are multiples of 3 * & 5 below N. */ #include <stdio.h> /** Main function */ int main() { int t; printf("Enter number of times you want to try"); scanf("%d", &...
thealgorithms-c/project_euler/problem_1/sol4.c
algorithms
thealgorithms-c
thealgorithms-c/project_euler/problem_1
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.323
false
false
805
-1
#include <stdio.h> /* By comparison, binary search always chooses the middle of the remaining * search space, discarding one half or the other, depending on the comparison * between the key found at the estimated position and the key sought. The * remaining search space is reduced to the part before or after the es...
thealgorithms-c/searching/interpolation_search.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.347
false
false
2,002
-1
/** * @file * @brief Function to convert a Cartesian co-ordinate to polar form. */ #define _USE_MATH_DEFINES /**< required for MS Visual C */ #include <assert.h> #include <math.h> #include <stdio.h> #include <stdlib.h> /** * @brief Function to convert cartesian coordinates to polar. *\f{eqnarray*}{ r &=& \sqrt{x...
thealgorithms-c/math/cartesian_to_polar.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.281
false
false
2,626
-1
int findComplement(int num) { int TotalBits = 0; int temp = num; while (temp) { // To find position of MSB in given num. Since num is represented as a // standard size in memory, we cannot rely on size for that information. TotalBits++; // increment TotalBits till temp becomes 0 ...
thealgorithms-c/leetcode/src/476.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.208
false
false
967
-1
/** * \file * \authors [Krishna Vedala](https://github.com/kvedala) * \brief Solve a multivariable first order [ordinary differential equation * (ODEs)](https://en.wikipedia.org/wiki/Ordinary_differential_equation) using * [forward Euler * method](https://en.wikipedia.org/wiki/Numerical_methods_for_ordinary_diffe...
thealgorithms-c/numerical_methods/ode_forward_euler.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.497
false
false
5,371
-1
void swap(int *x, int *y){ if (x==y) return; *x = *x + *y; *y= *x - *y; *x= *x - *y; } void sortColors(int* arr, int n){ int start=0, mid=0, end=n-1; while(mid<=end){ if(arr[mid]==1) mid++; else if(arr[mid]==0){ swap(&arr[mid],&arr[start]); ...
thealgorithms-c/leetcode/src/75.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.13
false
false
453
-1
char *getOne(char c) { switch (c) { case '9': return "IX"; case '8': return "VIII"; case '7': return "VII"; case '6': return "VI"; case '5': return "V"; case '4': return "IV"; case '3': return "III"; case '2': ...
thealgorithms-c/leetcode/src/12.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0
false
false
2,241
-1
/** * @addtogroup hash Hash algorithms * @{ * @file hash_xor8.c * @author [Christian Bender](https://github.com/christianbender) * @brief 8-bit [XOR hash](https://en.wikipedia.org/wiki/XOR_cipher) algorithm * for ASCII characters */ #include <assert.h> #include <inttypes.h> #include <stdio.h> /** * @brief 8-bi...
thealgorithms-c/hash/hash_xor8.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.489
false
false
989
-1
// Recursion problem // Given the denominations of currencies available in a system, find the number // of ways an ATM machine can generate notes for an entered amount N. #include <stdio.h> #include <stdlib.h> int ways(int n, int *a, int k) { if (n < 0 || k < 0) return 0; if (n == 0) return 1;...
thealgorithms-c/misc/demonetization.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.119
false
false
923
-1
#include "dynamic_array.h" #include <stdio.h> #include <stdlib.h> #include <string.h> dynamic_array_t *init_dynamic_array() { dynamic_array_t *da = malloc(sizeof(dynamic_array_t)); da->items = calloc(DEFAULT_CAPACITY, sizeof(void *)); da->capacity = DEFAULT_CAPACITY; return da; } void *add(dynamic_ar...
thealgorithms-c/data_structures/dynamic_array/dynamic_array.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/dynamic_array
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.065
false
false
1,715
-1
// Bit manipulation. // - Find the bit length of n using log2 // - Create bit mask of bit length of n // - Retun ~n and bit of ones mask // Runtime: O(log2(n)) // Space: O(1) int bitwiseComplement(int n){ if (n == 0){ return 1; } int binary_number_length = ceil(log2(n)); return (~n) & ((1 << b...
thealgorithms-c/leetcode/src/1009.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.462
false
false
349
-1
/** * @file * @author [Nikhill Vombatkere](https://github.com/NVombat) * @brief Client-side implementation of [TCP Half Duplex * Communication](http://www.tcpipguide.com/free/t_SimplexFullDuplexandHalfDuplexOperation.htm) * @see tcp_half_duplex_server.c * * @details * The algorithm is based on the simple TCP cl...
thealgorithms-c/client_server/tcp_half_duplex_client.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.738
false
false
6,221
-1
/** * @file * @brief Printing the [words contained in a * file](http://www.dailyfreecode.com/Code/word-list-reads-text-file-makes-2050.aspx) * named `file.txt` in alphabetical order and also their frequencies in to * another file "wordcount.txt" * @details * Given a file (`file.txt`) containing words (like a pub...
thealgorithms-c/data_structures/binary_trees/words_alphabetical.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/binary_trees
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.345
false
false
10,526
-1
// Queue ADT header file ... COMP2521 typedef struct QueueRep *queue; queue newQueue(); // set up empty queue void dropQueue(queue); // remove unwanted queue int QueueIsEmpty(queue); // check whether queue is empty void QueueEnqueue(queue, int); // insert an int at end of queue int Queu...
thealgorithms-c/data_structures/graphs/queue.h
algorithms
thealgorithms-c
thealgorithms-c/data_structures/graphs
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.793
false
false
1,810
-1
#include <stdio.h> void max_heapify(int *a, int i, int n); void heapsort(int *a, int n); void build_maxheap(int *a, int n); void max_heapify(int *a, int i, int n) { int j, temp; temp = a[i]; j = 2 * i; while (j <= n) { if (j < n && a[j + 1] > a[j]) j = j + 1; if (temp >...
thealgorithms-c/sorting/heap_sort.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.015
false
false
1,215
-1
#include <ctype.h> #include <stdio.h> #include <string.h> char *abbreviate(const char *phrase) { char str[80]; strcpy(str, phrase); char *p_str = str; static char acr[80]; strcpy(acr, ""); /* for counting the words */ int counter = 0; /* for position the words */ int index = 0; ...
thealgorithms-c/exercism/acronym/acronym.c
algorithms
thealgorithms-c
thealgorithms-c/exercism/acronym
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.211
false
false
1,753
-1
#include <stdio.h> int largest(int a[], int n) { int large = a[0], i; for (i = 1; i < n; i++) { if (large < a[i]) large = a[i]; } return large; } void RadixSort(int a[], int n) { int bucket[10][10], bucket_count[10]; int i, j, k, remainder, NOP = 0, divisor = 1, large, ...
thealgorithms-c/sorting/radix_sort.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.016
false
false
1,477
-1
/** * \file * \brief [Problem 12](https://projecteuler.net/problem=12) solution * \author [Krishna Vedala](https://github.com/kvedala) */ #include <math.h> #include <stdio.h> #include <stdlib.h> /** * Get number of divisors of a given number * * If \f$x = a \times b\f$, then both \f$a\f$ and \f$b\f$ are divisor...
thealgorithms-c/project_euler/problem_12/sol1.c
algorithms
thealgorithms-c
thealgorithms-c/project_euler/problem_12
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.383
false
false
1,353
-1
/** * @file * @brief Octal to hexadecimal conversion by scanning user input * @details * The octalToHexadecimal function take the octal number as long * return a string hexadecimal value after conversion * @author [Rachit Bhalla](https://github.com/rachitbhalla) */ #include <assert.h> // for assert #include <mat...
thealgorithms-c/conversions/octal_to_hexadecimal.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.586
false
false
2,391
-1
void duplicateZeros(int *arr, int arrSize) { int i, start = 0; int *tmp = malloc(arrSize * sizeof(int)); /* Copy arr into tmp arr */ for (i = 0; i < arrSize; i++) { tmp[i] = arr[i]; } i = 0; for (start = 0; start < arrSize; start++) { arr[start] = tmp[i]; if (...
thealgorithms-c/leetcode/src/1089.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.045
false
false
460
-1
/** * @file * @brief [Bubble sort](https://en.wikipedia.org/wiki/Bubble_sort) algorithm * implementation using recursion. */ #include <assert.h> #include <stdbool.h> #include <stdio.h> #include <stdlib.h> #include <time.h> /** * Swapped two numbers using pointer * @param first first pointer of first number * @p...
thealgorithms-c/sorting/bubble_sort_recursion.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.384
false
false
1,452
-1
/** * @file tic-tac-toe.c * @author [vivekboss99](github.com/vivekboss99) * @author [Krishna Vedala](https://github.com/kvedala) * @brief [Tic-Tac-Toe game](https://en.wikipedia.org/wiki/Tic-tac-toe) * implementation in C * @details Tic-Tac-Toe Game, where the user can decide to play with the * computer(single ...
thealgorithms-c/games/tic_tac_toe.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.162
false
false
9,976
-1
/** * \file * \brief [Problem 26](https://projecteuler.net/problem=26) solution * \author [Krishna Vedala](https://github.com/kvedala) */ #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> #ifdef _OPENMP #include <omp.h> #endif #define MAX_DENO 2000 /**< limit of unit fractions */ #define...
thealgorithms-c/project_euler/problem_26/sol1.c
algorithms
thealgorithms-c
thealgorithms-c/project_euler/problem_26
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.388
false
false
2,398
-1
int *twoSum(int *nums, int numsSize, int target, int *returnSize) { int i, j; int *ret = calloc(2, sizeof(int)); for (i = 0; i < numsSize; i++) { int key = target - nums[i]; for (j = i + 1; j < numsSize; j++) if (nums[j] == key) { ret[0] = i; ...
thealgorithms-c/leetcode/src/1.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.059
false
false
402
-1
#define min(x,y)(((x)<(y))?(x):(y)) // DP up -> down. We are going down from gridline to gridline // and collect the minumum cost path. // Runtime : O(gridSize*gridColSize*gridColSize) // Space: O(gridColSize) int minPathCost(int** grid, int gridSize, int* gridColSize, int** moveCost, int moveCostSize, int* moveCostCo...
thealgorithms-c/leetcode/src/2304.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.206
false
false
1,387
-1
/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct TreeNode *searchBST(struct TreeNode *root, int val) { if (!root) return NULL; if (root->val == val) { return root; } else if ...
thealgorithms-c/leetcode/src/700.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.32
false
false
460
-1
/* author: Christian Bender public interface for the dictionary. The dictionary prepares space for 1000 elements. */ #ifndef __DICT__H #define __DICT__H #define MAXELEMENTS 1000 /* special data type called 'Dictionary' for generic use */ typedef struct Dict { /* void* array for gener...
thealgorithms-c/data_structures/dictionary/dict.h
algorithms
thealgorithms-c
thealgorithms-c/data_structures/dictionary
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.442
false
false
1,432
-1
#include <math.h> #include <stdio.h> #include <stdlib.h> typedef struct node { int val; struct node *par; struct node *left; struct node *right; int color; } Node; // Create a new node Node *newNode(int val, Node *par) { Node *create = (Node *)(malloc(sizeof(Node))); create->val = val; ...
thealgorithms-c/data_structures/binary_trees/red_black_tree.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/binary_trees
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.128
false
false
21,228
-1
/** * Note: The returned array must be malloced, assume caller calls free(). */ int find(int* sets, int index){ while (sets[index] != index){ index = sets[index]; } return index; } void unionSet(int* sets, int i1, int i2){ int i1Parent = find(sets, i1); int i2Parent = find(sets, i2); ...
thealgorithms-c/leetcode/src/684.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.179
false
false
1,094
-1
// Prefix sum. // Collect sum fromleft part and compare it with left sum. // Runtime: O(n) // Space: O(1) int waysToSplitArray(int* nums, int numsSize){ long sumNums = 0; for (int i = 0; i < numsSize; i++){ sumNums += nums[i]; } long prefixSum = 0; int result = 0; for (int i = 0; i ...
thealgorithms-c/leetcode/src/2270.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.211
false
false
482
-1
// Using hashtable. // Runtime: O(n + len(trust)) // Space: O(n) int findJudge(int n, int** trust, int trustSize, int* trustColSize){ int* personsToTrust = calloc(n + 1, sizeof(int)); int* personsFromTrust = calloc(n + 1, sizeof(int)); for(int i = 0; i < trustSize; i++){ int* currentTrust = trust[i...
thealgorithms-c/leetcode/src/997.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.125
false
false
795
-1
/** * @file * @brief Header file that contains macros used to replace malloc/calloc and free. * @details * Macros malloc, calloc and free respectively calls malloc_dbg, calloc_dbg and free_dbg. * malloc_dbg and calloc_dbg allocates memory using the "real" malloc and calloc and store * the pointer returned (with a...
thealgorithms-c/developer_tools/malloc_dbg.h
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.852
false
false
1,292
-1
/** * @file * @author [jucollet972](https://github.com/jucollet972) * @brief [Decimal to any-base](http://codeofthedamned.com/index.php/number-base-conversion) is a C function wich convert positive decimal * integer to any positive ascii base with the base's alphabet given in input and return it in a dynamically al...
thealgorithms-c/conversions/decimal_to_any_base.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.392
false
false
4,301
-1
#include "list.h" #include <assert.h> #include <stdarg.h> #include <stddef.h> #include <stdio.h> #include <stdlib.h> #define L List_T /* Initial list */ L List_init(void) { L list; list = (L)malloc(sizeof(L)); list->next = NULL; return list; } /* Push an element into top of the list */ L List_push(L ...
thealgorithms-c/data_structures/list/list.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/list
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.229
false
false
1,366
-1
int maxNumberOfBalloons(char *text) { /* 0 -> b, 1 -> a, 2 -> l, 3 -> o, 4 -> n */ int count_letters[5] = {0}; int i, min_counter_ballons; for (char *ptr = text; *ptr; ptr++) { if (*ptr == 'b') { count_letters[0]++; } ...
thealgorithms-c/leetcode/src/1189.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.106
false
false
1,086
-1
#include <stdio.h> #include <string.h> /* Naive Pattern Search algorithm (brute force way) */ void naive_search(char *str, char *pattern) { int len_str = strlen(str); int len_pat = strlen(pattern); for (int i = 0; i <= len_str - len_pat; i++) { int j; for (j = 0; j < len_pat; j++) ...
thealgorithms-c/searching/pattern_search/naive_search.c
algorithms
thealgorithms-c
thealgorithms-c/searching/pattern_search
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.088
false
false
928
-1
/** * \file * \brief [Problem 14](https://projecteuler.net/problem=14) solution * \author [Krishna Vedala](https://github.com/kvedala) * * Since the computational values for each iteration step are independent, * we can compute them in parallel. However, the maximum values should be * updated in synchrony so tha...
thealgorithms-c/project_euler/problem_14/sol1.c
algorithms
thealgorithms-c
thealgorithms-c/project_euler/problem_14
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.457
false
false
2,138
-1
/** * @file * @brief [Prime Sieve](https://leetcode.com/problems/count-primes/) * algorithm implementation. * @author [Divyansh Kushwaha](https://github.com/webdesignbydivyansh) */ #include <assert.h> /// for assert #include <stdio.h> /// for standard input output #include <stdlib.h> /// for general purpose standa...
thealgorithms-c/math/prime_sieve.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.486
false
false
1,714
-1
/** * Definition for a binary tree node. * struct TreeNode { * int val; * struct TreeNode *left; * struct TreeNode *right; * }; */ struct NodeDistributeInfo { int distributeMoves; int distributeExcess; }; struct NodeDistributeInfo* getDisturb(struct TreeNode* node) { struct NodeDistribu...
thealgorithms-c/leetcode/src/979.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.368
false
false
1,456
-1
// Counting whole summ. evens sums number and odd summs number. // Runtime: O(n), // Space: O(1) int numOfSubarrays(int* arr, int arrSize){ int result = 0; int curSumm = 0; int currOddSumms = 0; int currEvenSumm = 0; int modulo = 1000000000 + 7; for(int i = 0; i < arrSize; i++){ curSumm...
thealgorithms-c/leetcode/src/1524.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.136
false
false
605
-1
#define min(x, y) (((x) < (y)) ? (x) : (y)) bool isWordLess(char* word1, char* word2, int* charOrder){ int word1Length = strlen(word1); int word2Length = strlen(word2); for(int i = 0; i < min(word1Length, word2Length); i++) { int charWordsDiff = (charOrder[word1[i] - 'a'] - charOrder[word2[i] ...
thealgorithms-c/leetcode/src/953.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.129
false
false
1,012
-1
/** * \file * \brief [Problem 8](https://projecteuler.net/problem=8) solution * \author [Krishna Vedala](https://github.com/kvedala) */ #include <stdio.h> #include <stdlib.h> #include <string.h> /* for memmove */ /** Main function */ int main(int argc, char *argv[]) { int position = 0, num_bad_chars = 0; i...
thealgorithms-c/project_euler/problem_8/sol2.c
algorithms
thealgorithms-c
thealgorithms-c/project_euler/problem_8
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.281
false
false
3,656
-1
char *countAndSay(int n) { // Calculating the length of array double result = 1.0; for (int i = 0; i < n - 1; i++) { result *= 1.4; } int k, j, count, convert = (int)result; // Creating array with the length calculated above char *arr = malloc(convert + 4); arr[0] = '1'; ...
thealgorithms-c/leetcode/src/38.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.049
false
false
956
-1
/** * @file * @brief [Insertion sort](https://en.wikipedia.org/wiki/Insertion_sort) * algorithm implementation. */ #include <assert.h> #include <stdio.h> #include <stdlib.h> #include <time.h> /** * Insertion sort algorithm implements * @param arr array to be sorted * @param size size of array */ void insertion...
thealgorithms-c/sorting/insertion_sort.c
algorithms
thealgorithms-c
thealgorithms-c
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.375
false
false
1,311
-1
#include <stdbool.h> #include <string.h> /* is_isogram: returns true if the given string a isogram, otherwise false. */ bool is_isogram(const char phrase[]) { /* use 'unsigned' because of the function strlen(...) */ unsigned int i = 0; unsigned int j = 0; /* the current read character in the first...
thealgorithms-c/exercism/isogram/isogram.c
algorithms
thealgorithms-c
thealgorithms-c/exercism/isogram
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.324
false
false
1,060
-1
/** * @file segment_tree.c * @brief segment trees with only point updates * @details * This code implements segment trees. Segment trees are general structures * which allow range based queries in a given array in logN time. * Segment tree with point updates allow update of single element in the array * in logN ...
thealgorithms-c/data_structures/binary_trees/segment_tree.c
algorithms
thealgorithms-c
thealgorithms-c/data_structures/binary_trees
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.462
false
false
7,304
-1
#define MAP_SIZE 2048 int cmpvalue(const void *a, const void *b) { return *(int *)b - *(int *)a; } bool uniqueOccurrences(int *arr, int arrSize) { int *map = calloc(MAP_SIZE, sizeof(int)); int i; for (i = 0; i < arrSize; i++) { if (arr[i] < 0) map[arr[i] + MAP_SIZE / 2] += 1; ...
thealgorithms-c/leetcode/src/1207.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.08
false
false
626
-1
/* Boyer-Moore Majority Vote Algorithm * http://www.cs.utexas.edu/~moore/best-ideas/mjrty/ */ int majorityElement(int *nums, int numsSize) { int count = 1; int majorNum = nums[0]; for (int i = 1; i < numsSize; i++) { if (count == 0) { majorNum = nums[i]; count++;...
thealgorithms-c/leetcode/src/169.c
algorithms
thealgorithms-c
thealgorithms-c/leetcode/src
GPL-3.0
GPL-3.0
e5dad3fa8def3726ec850ca66a7f51521f8ad393
c
false
0.1
false
false
453
-1