id int64 0 755k | file_name stringlengths 3 109 | file_path stringlengths 13 185 | content stringlengths 31 9.38M | size int64 31 9.38M | language stringclasses 1
value | extension stringclasses 11
values | total_lines int64 1 340k | avg_line_length float64 2.18 149k | max_line_length int64 7 2.22M | alphanum_fraction float64 0 1 | repo_name stringlengths 6 65 | repo_stars int64 100 47.3k | repo_forks int64 0 12k | repo_open_issues int64 0 3.4k | repo_license stringclasses 9
values | repo_extraction_date stringclasses 92
values | exact_duplicates_redpajama bool 2
classes | near_duplicates_redpajama bool 2
classes | exact_duplicates_githubcode bool 2
classes | exact_duplicates_stackv2 bool 1
class | exact_duplicates_stackv1 bool 2
classes | near_duplicates_githubcode bool 2
classes | near_duplicates_stackv1 bool 2
classes | near_duplicates_stackv2 bool 1
class |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
25,815 | pstring_test.cpp | mandliya_algorithms_and_data_structures/string_problems/pstring_test.cpp | /*
30 unit tests testing pstring library ( a string library)
located in include/pstring.cpp
include/pstring.h
include/pUnitTest.h
include/pUnitTest.cpp
*/
#include <cstdio>
#include "pUnitTest.h"
#include "pstring.h"
bool summary_flag = false;
unsigned long int tpass = 0, tfail = 0;
using string = al... | 2,917 | C++ | .cpp | 74 | 34.756757 | 127 | 0.544326 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,816 | robinKarpStringMatching.cpp | mandliya_algorithms_and_data_structures/string_problems/robinKarpStringMatching.cpp | /*
* Given a string pattern(P) and large Text string (T), Write a function search( P , T) which provide all the occurrences of P in T.
* example : T => "AABAACAADAABAAABAA".
* P => "AABA"
* Output : 0, 9, 13 ( all indices of T where pattern string P is starts to match.
*
* Approach:
* Lets say ... | 4,205 | C++ | .cpp | 112 | 31.357143 | 132 | 0.506558 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,817 | z.cpp | mandliya_algorithms_and_data_structures/string_problems/z.cpp | #include <iostream>
#include <string>
#include <vector>
/**
* Function to fill in zvalues vector of ztext
*/
std::vector<size_t> fillZvalues(const std::string & ztext) {
size_t n = ztext.length();
std::vector<size_t> zvals(n, 0);
size_t L = 0, R = 0; // s[L..R] represent the prefix string.
for (size_t i... | 1,555 | C++ | .cpp | 62 | 22.387097 | 87 | 0.587643 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,818 | length_of_last_word.cpp | mandliya_algorithms_and_data_structures/string_problems/length_of_last_word.cpp | /*
* Given a string consisting of lower/upper case alphabets and empty space character ' '.
* Return the length of last word in the string.
*
* A word is character sequence containing non-space characters only.
*
* Return 0, if no last word exist.
*
* Approach:
*
* Start from end of the string, ... | 1,794 | C++ | .cpp | 48 | 32.125 | 130 | 0.58425 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,819 | find_difference.cpp | mandliya_algorithms_and_data_structures/string_problems/find_difference.cpp | /*
* Find the difference between two string.
* String t is generated by random shuffling string s and then add
* one more letter at a random position.
* Determine the character which is different in t.
*
* Approach: Since only one letter is different between s and t,
* we could try XOR approach.
* XOR of a... | 827 | C++ | .cpp | 29 | 25.034483 | 70 | 0.633838 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,820 | next_permutation.cpp | mandliya_algorithms_and_data_structures/string_problems/next_permutation.cpp | /**
* Implement next permutation algorithm. i.e
* Given a word w, rearrange the letters of w to construct another word s in such a way that
* s is lexicographically greater than w.
* In case of multiple possible answers, find the lexicographically smallest one.
* Example:
* ab --> ba
* bb --> bb
* hefg ... | 1,237 | C++ | .cpp | 51 | 21.333333 | 93 | 0.591716 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,821 | queueDemo.cpp | mandliya_algorithms_and_data_structures/queue_problems/queueDemo.cpp | #include <iostream>
#include "../include/queue.h"
#include "../include/generic.h"
int main()
{
const int QUEUE_SIZE = 10;
algo::Queue<int> Q(QUEUE_SIZE);
std::cout << "Pushing following values to queue:\n";
for ( int i = 0; i < QUEUE_SIZE; ++i )
{
int rand_value = algo::random_range( 5, 5... | 666 | C++ | .cpp | 24 | 23.041667 | 64 | 0.538341 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,822 | node_ancestors_in_root_path.cpp | mandliya_algorithms_and_data_structures/tree_problems/node_ancestors_in_root_path.cpp | /**
* Given a binary Tree
* 1
* / \
* 2 3
* / \
* 4 5
* \
* 6
*
* Ancestor of node 6 in root path would be 4, 2, and 1.
*
*/
#include <iostream>
#include <vector>
struct Node {
int data;
Node * left;
Node * right;
Node( int d ) : data{ d... | 1,403 | C++ | .cpp | 62 | 20.467742 | 79 | 0.584835 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,823 | find_target_k.cpp | mandliya_algorithms_and_data_structures/tree_problems/find_target_k.cpp | /*
* Given a Binary Search Tree and a target number,
* return true if there exist two elements in the BST such that their sum is equal to the given target.
*
* Input:
* 5
* / \
* 3 6
* / \ \
* 2 4 7
*
* Target = 9
* Output: True
*
* Target = 28
* Output: False
*
* Approach:
*
... | 2,195 | C++ | .cpp | 79 | 23.746835 | 109 | 0.617284 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,824 | sortedArrayToBST.cpp | mandliya_algorithms_and_data_structures/tree_problems/sortedArrayToBST.cpp | /**
* Given a sorted array, convert it balaned binary search tree.
*/
#include<iostream>
#include<vector>
struct Node {
int data;
Node * left;
Node * right;
Node( int d ) : data{ d }, left{ nullptr }, right{ nullptr } { }
};
Node * sortedArrayToBST( std::vector<int> & arr, int start, int end ) {
if ( start > ... | 1,074 | C++ | .cpp | 44 | 22.454545 | 71 | 0.62207 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,826 | k_sum_paths.cpp | mandliya_algorithms_and_data_structures/tree_problems/k_sum_paths.cpp | /*
* Given a binary tree, print all the paths whose sum is equal to k
* 1
* / \
* 3 -1
* / \ / \
* 2 1 4 5
* / / \ \
* 1 1 2 6
*
* For k = 5:
* 3 2
* 3 1 1
* 1 3 1
* 4 1... | 2,390 | C++ | .cpp | 95 | 18.936842 | 75 | 0.492091 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,828 | lowest-common-ancestor-binary-tree.cpp | mandliya_algorithms_and_data_structures/tree_problems/lowest-common-ancestor-binary-tree.cpp | /*
* We did lowest common ancestor of a binary SEARCH tree in a different problem.
* This will provide lowest common ancestor of a binary tree.
* Example
* 20
* / \
* 24 22
* / \
* 25 12
* / \
* 10 14
*
* In the above tree, LCA ... | 2,104 | C++ | .cpp | 65 | 27.907692 | 97 | 0.594074 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,829 | string_from_tree.cpp | mandliya_algorithms_and_data_structures/tree_problems/string_from_tree.cpp | /*
* Given a binary tree, traversing preorder, construct a string output
* containing node values and parenthesis.
* The null node needs to be represented by empty parenthesis pair "()".
* And you need to omit all the empty parenthesis pairs that don't affect
* the one-to-one mapping relationship between the strin... | 1,858 | C++ | .cpp | 65 | 24.784615 | 79 | 0.593277 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,830 | kth_smallest.cpp | mandliya_algorithms_and_data_structures/tree_problems/kth_smallest.cpp | /*
* Given a binary search tree, find the kth smallest element in it.
* Assumption: k is always valid i.e. 1 <= k <= total number of nodes in BST
*
* 8
* / \
* / \
* 4 10
* / \ / \
* / \ / \
* 2 6 9 12
* k = 2, answer: 4
* k = 7, answer: 12
... | 2,087 | C++ | .cpp | 82 | 20 | 76 | 0.553581 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,831 | validate_bst.cpp | mandliya_algorithms_and_data_structures/tree_problems/validate_bst.cpp | /*
* Validate if a given binary tree is a binary search tree.
*
* Example:
*
* 10
* / \
* 5 15
*
* Answer: True
*
* Example:
*
* 10
* / \
* 5 15
* / \ / \
* 2 7 9 17
*
* Answer : False
*/
#incl... | 2,145 | C++ | .cpp | 84 | 21 | 87 | 0.559727 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,832 | levelOrderTraversalIterative.cpp | mandliya_algorithms_and_data_structures/tree_problems/levelOrderTraversalIterative.cpp | /*
* Program to implement level order traversal - iterative version
*/
#include <iostream>
#include <queue.h>
const int maxNodes = 15;
struct Node
{
int data;
Node* left;
Node* right;
};
/*
* An helper function to get a new node
*/
Node* newNode( int data )
{
Node *temp = new Node;
temp->da... | 1,612 | C++ | .cpp | 86 | 13.697674 | 65 | 0.531044 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,833 | level_of_node.cpp | mandliya_algorithms_and_data_structures/tree_problems/level_of_node.cpp | /**
* Given a Binary Tree and a key, write a function that returns level of the key.
* 3
* / \
* 2 5
* / \
* 1 4
*
* Here 3 is on level 1
* 2 and 5 have level 2
* 1 and 4 have level 3
* If key not in tree, return 0
*
*/
#include <iostream>
struct Node {
int data;
Node * left;
Node ... | 1,212 | C++ | .cpp | 52 | 21.384615 | 101 | 0.603806 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,834 | convert_to_sum_tree.cpp | mandliya_algorithms_and_data_structures/tree_problems/convert_to_sum_tree.cpp | /**
* Convert a given tree to to sum tree.
* Given : A tree with positive and negative data values.
* Convert this to a tree where each node contains the sum of the left and right sub trees in the original tree.
* The values of leaf nodes are changed to 0.
* 10 20
* ... | 1,872 | C++ | .cpp | 62 | 27.419355 | 112 | 0.575791 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,835 | reverseLevelOrderTraversal.cpp | mandliya_algorithms_and_data_structures/tree_problems/reverseLevelOrderTraversal.cpp | /*
* Reverse Level Order Traversal of Binary Tree
* Given a binary tree, print its nodes level by level in reverse order.
* i.e. all nodes present at last level should be printed first followed
* by nodes of second-last level and so on..
* All nodes for any level should be printed from left to right.
*
* ... | 2,152 | C++ | .cpp | 80 | 20.6125 | 73 | 0.553493 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,836 | levelOrderTraversalRecursive.cpp | mandliya_algorithms_and_data_structures/tree_problems/levelOrderTraversalRecursive.cpp | /*
* Level order BST traveral iterative
*/
#include <iostream>
struct Node
{
int data;
Node *left;
Node *right;
};
Node* newNode( int data )
{
Node *temp = new Node;
temp->data = data;
temp->left = temp->right = nullptr;
return temp;
}
void insert( Node* & node, int data)
{
if ( ... | 1,577 | C++ | .cpp | 86 | 13.313953 | 79 | 0.520594 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,837 | lowest-common-ancestor.cpp | mandliya_algorithms_and_data_structures/tree_problems/lowest-common-ancestor.cpp | /**
* Given a binary search tree, determine the lowest common ancestor of two given nodes with data
* key1 and key2. Assumption is key1 and key2 exists in tree
* Example
* 20
* / \
* 8 22
* / \
* 4 12
* / \
* 10 14
*
* In th... | 1,851 | C++ | .cpp | 65 | 24.969231 | 97 | 0.557055 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,838 | closest_bst_value.cpp | mandliya_algorithms_and_data_structures/tree_problems/closest_bst_value.cpp | /*
* Given a non-empty binary search tree and a target value,
* find the value in the BST that is closest to the target.
* Also, to note that the target value is a floating point.
* There will be only one unique value which is closest to the target.
*/
#include <iostream>
#include <limits>
#include <cmath>
stru... | 2,070 | C++ | .cpp | 66 | 26.681818 | 84 | 0.627825 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,839 | sumTree.cpp | mandliya_algorithms_and_data_structures/tree_problems/sumTree.cpp | /**
* Problem: Determine if a tree is sum tree.
* A SumTree is a Binary Tree where the value of a node is equal to sum of the nodes present in its left subtree and right subtree.
* An empty tree is SumTree and sum of an empty tree can be considered as 0.
* A leaf node is also considered as SumTree.
*
* 26... | 1,836 | C++ | .cpp | 79 | 20.21519 | 131 | 0.552511 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,841 | floor_ceil_bst.cpp | mandliya_algorithms_and_data_structures/tree_problems/floor_ceil_bst.cpp | /*
* Given a BST, find ceil and floor of a given key in it. If the given key lie in the BST,
* then both floor and ceil is equal to that key, else ceil is equal to next greater key (if any)
* in the BST and floor is equal to previous greater key (if any) in the BST.
* source : techiedelight.com
*
* ... | 2,934 | C++ | .cpp | 108 | 20.537037 | 100 | 0.546228 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,842 | verticalSum.cpp | mandliya_algorithms_and_data_structures/tree_problems/verticalSum.cpp | /**
* Given a binary Tree
* 1
* / \
* 2 3
* / \ / \
* 4 5 6 7
*
* Find vertical sums of the tree.
* Align the nodes in vertical line.
* Here
* The tree has 5 vertical lines
*
* Vertical-Line-1 has only one node 4 => vertical sum is 4
* Vertical-Line-2: has o... | 1,964 | C++ | .cpp | 69 | 26.449275 | 126 | 0.628375 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,844 | predecessorSuccessor.cpp | mandliya_algorithms_and_data_structures/tree_problems/predecessorSuccessor.cpp | /*
* Goal : To find successor and predecessor ( if exists ) of a key in Binary Search Tree
*
*/
#include <iostream>
#include <generic.h>
/* Node of the tree */
struct Node {
int data;
Node *left;
Node *right;
};
// Helper function to return a new node
Node* newNode( const int & data )
{
Node *nod... | 2,391 | C++ | .cpp | 94 | 19.734043 | 89 | 0.539001 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,848 | save_quantamland.cpp | mandliya_algorithms_and_data_structures/common_ds_algo_problems/save_quantamland.cpp | /**
* In Quantumland, there are n cities numbered from 1 to n. Here, ci denotes the ith city.
* There are n−1 roads in Quantumland. Here, ci and ci+1 have a bidirectional road between them for each i<n.
* There is a rumor that Flatland is going to attack Quantumland, and the queen wants to keep her land safe.
* T... | 1,765 | C++ | .cpp | 69 | 22.913043 | 111 | 0.632327 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | true | false |
25,849 | vigenere_cipher.cpp | mandliya_algorithms_and_data_structures/common_ds_algo_problems/vigenere_cipher.cpp | /**
* Implements a program which encrypts and then decrypts text using Vigenère cipher.
* The Vigenère cipher is a method of encrypting alphabetic text by using a series of interwoven Caesar ciphers based on the letters of a keyword.
* Refer : https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher
*
* Enter the key fo... | 3,707 | C++ | .cpp | 92 | 33.23913 | 146 | 0.620959 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | true | false |
25,850 | rotate_matrix.cpp | mandliya_algorithms_and_data_structures/common_ds_algo_problems/rotate_matrix.cpp | /**
* Given a 2D matrix, a, of dimension MxN and a positive integer R.
* You have to rotate the matrix R times and print the resultant matrix.
* Rotation should be in anti-clockwise direction.
*
* Input : First line contains M (number of rows of matrix), N (number of columns in matrix)
* and R (Number of... | 2,888 | C++ | .cpp | 112 | 19.4375 | 101 | 0.449783 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | true | false |
25,852 | findDigits.cpp | mandliya_algorithms_and_data_structures/common_ds_algo_problems/findDigits.cpp | /**
* You are given an integer N. Find the digits in this number that exactly divide N (division that leaves 0 as remainder) and display their count.
* For N=24, there are 2 digits (2 & 4). Both of these digits exactly divide 24. So our answer is 2.
*
* Note
*
* If the same number is repeated twice at different p... | 1,342 | C++ | .cpp | 55 | 20.309091 | 146 | 0.602033 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,853 | n_binary.cpp | mandliya_algorithms_and_data_structures/common_ds_algo_problems/n_binary.cpp | /*
* Generate numbers between 1 to N, in binary using a data-structure.
*/
#include <iostream>
#include <string>
#include <queue>
void print_n_binary(int n)
{
std::queue<std::string> q;
q.push("1");
int i = 1;
while (i++ <= n)
{
// append 0 and 1 to the existing binary st... | 611 | C++ | .cpp | 29 | 15.551724 | 70 | 0.505226 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | true | false |
25,854 | power_function.cpp | mandliya_algorithms_and_data_structures/common_ds_algo_problems/power_function.cpp | /*
* Implement pow(a, b) function.
* We can recursively call a sub-problem
* if n is even, then pow(a,b) = pow(a, b/2) * pow(a, b/2);
* if n is odd then, pow(a, b) = a * pow(a, b/2) * pow(a, b/2);
*/
#include <iostream>
int power(int a, int b)
{
// base condition
//
if (b == 0)
{
... | 829 | C++ | .cpp | 39 | 15.717949 | 64 | 0.455013 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,855 | caeser_cipher.cpp | mandliya_algorithms_and_data_structures/common_ds_algo_problems/caeser_cipher.cpp | /*
* Encrypts a plain text to decrypts an encrypted text back to plain using Caeser Cipher.
* It is a type of substitution cipher in which each letter in the plaintext is replaced by a
* letter some fixed number of positions down the alphabet. For example, with a left shift of 3,
* D would be replaced by A, E w... | 2,510 | C++ | .cpp | 77 | 27.207792 | 97 | 0.59666 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | true | false |
25,857 | matrix_spiral_print.cpp | mandliya_algorithms_and_data_structures/common_ds_algo_problems/matrix_spiral_print.cpp | /**
* Given a m * n matrix, print the contents of it spiral way. for example.
* Matrix is :
* 1 2 3 4 5
* 6 7 8 9 10
* 11 12 13 14 15
* 16 17 18 19 20
* Sprial order print would
* 1 2 3 4 5 10 15 20 19 18 17 16 11 6 7 8 9 14 13 12
*/
#include <iostream>
void spiral_print_matr... | 1,381 | C++ | .cpp | 56 | 20.821429 | 75 | 0.459726 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,858 | max_subsequence.cpp | mandliya_algorithms_and_data_structures/dynamic_programming_problems/max_subsequence.cpp | /**
* Maximum Value Contiguous Subsequence
* Given an array of n numbers, give an algorithm for finding a contigous
* subsequence A(i)...A(j) for which the sum of elements is maximum.
* Example - { -2, 11, -4, 13, -5, 2} --> 20 i.e. { 11, -4, 13}
* Example - { 1, -3, 4, -2, -1, 6} --> 7 { 4, -2, -1, 6}
*
* Appro... | 3,700 | C++ | .cpp | 121 | 26.933884 | 108 | 0.59332 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,859 | lcs.cpp | mandliya_algorithms_and_data_structures/dynamic_programming_problems/lcs.cpp | /**
* Given two strings X(1..m) and Y(1..n). Find the longest common substring
* that appears left to right (but not necessarily in a contiguous manner)
* in both strings. For example X = "ABCBDAB" and Y = "BDCABA"
* LCS(X,Y) = {"BCBA", "BDAB", "BCAB"}.
* LCS-LENGTH(X,Y) = 4
*/
#include <iostream>
#include <str... | 1,837 | C++ | .cpp | 68 | 24.455882 | 98 | 0.559932 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | true | false |
25,860 | 0_1_knapsack_problem.cpp | mandliya_algorithms_and_data_structures/dynamic_programming_problems/0_1_knapsack_problem.cpp | /*
* 0-1 Knapsack Problem: Imagine you are a thief and you want to steal things from room full of things.
* You have a knapsack which can handle maximum capacity of weight W, and you want to fill it up such
* that it's worth is maximum. Being an intelligent thief, you know weights and values of each item in the roo... | 2,598 | C++ | .cpp | 63 | 36.31746 | 114 | 0.642829 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | true | false |
25,861 | fibonacci.cpp | mandliya_algorithms_and_data_structures/dynamic_programming_problems/fibonacci.cpp | /**
* Calculating Fibonacci series term of index N using DP memoization.
*/
#include <iostream>
#include <vector>
//bottom up
int fib1(int n) {
std::vector<int> fib(n, 0);
if ( n == 0 || n == 1 ) {
return 1;
}
fib[0] = 1;
fib[1] = 1;
for ( int i = 2; i < n; ++i ) {
fib[i] = fib[i-1] + fib[i-2];
}
retur... | 907 | C++ | .cpp | 50 | 16.14 | 71 | 0.540636 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,862 | unique_paths.cpp | mandliya_algorithms_and_data_structures/dynamic_programming_problems/unique_paths.cpp | /*
* Level : Easy
* Given a grid, calculate the maximum number of unique paths
* from source (0,0) to destination (m, n). You can only move
* either in down or in right direction.
*
* S . . . . . . . .
* . . . . . . . . .
* . . . . . . . . .
* . . . . . . . . .
* . . . . . . . . .
* . . . . . . . . D
... | 993 | C++ | .cpp | 41 | 20.390244 | 64 | 0.472574 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,863 | catalan_number.cpp | mandliya_algorithms_and_data_structures/dynamic_programming_problems/catalan_number.cpp | /**
* Dynamic Programming problem
* Catalan number - How many binary search trees are possible with n keys.
* n = 1 , num of BST - 1
* n = 2 , num of BST - 2
*
* 2 1
* / and \
* 1 2
*
* n = 3, num of BST - 5
*
* ... | 1,583 | C++ | .cpp | 48 | 30.354167 | 80 | 0.440235 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,864 | primsMST.cpp | mandliya_algorithms_and_data_structures/graph_problems/primsMST.cpp | /**
* Minimum spanning tree using Prim's algorithm.
* Approach greedy
* Calculate the weight of minimum spanning tree(sum of weight of edges of MST)
* and print the edges which makes MST.
* Input format:
* ROW 1 :: V - number of vertices, E - number of Edges.
* Next E lines give details of each edge in format x ... | 2,938 | C++ | .cpp | 113 | 23.539823 | 93 | 0.560584 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,866 | flood_fill.cpp | mandliya_algorithms_and_data_structures/graph_problems/flood_fill.cpp | /*
* Given a 2D screen, location of the pixel and new value of the color to fill, replace the color of the
* pixel and all the adjacent(up, below, left, right) same colored pixel with new color.
*
* This is same as flood fill (remember the bucket symbol) a region in MS-PAINT.
*
* [[1 1 1 2 2 1 1]
* [1 1 1 2 1... | 2,419 | C++ | .cpp | 75 | 28.093333 | 109 | 0.590501 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,867 | grid_word_search.cpp | mandliya_algorithms_and_data_structures/graph_problems/grid_word_search.cpp | /*
* Search a given word in a 2D board containing letters.
* The word can be constructed by sequentially traversing adjacent
* horizontal or vertical cells. In a sequence to form word,
* letter on same position can not be used more than once.
*
* Example:
* Input:
*
* ['H' 'E' 'Y' 'A']
* ['O' 'L' 'A' 'Y']... | 3,757 | C++ | .cpp | 122 | 25.844262 | 86 | 0.565386 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,868 | kruskalMST.cpp | mandliya_algorithms_and_data_structures/graph_problems/kruskalMST.cpp | /**
* Given an undirected weighted connected graph, it is required to find the Really Special SubTree in it.
* The Really Special SubTree is defined as a subgraph consisting of all the nodes in the graph and
* There is only one exclusive path from a node to every other node.
* The subgraph is of minimum overall wei... | 4,036 | C++ | .cpp | 124 | 28.346774 | 113 | 0.620991 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,869 | dfsDemo.cpp | mandliya_algorithms_and_data_structures/graph_problems/dfsDemo.cpp | #include <iostream>
#include "graph.h"
/**
* Implementation of BFS algorithm is in ../include/graph.h
*/
int main()
{
std::vector<int> vec{ 0, 1, 2, 3, 4, 5, 6, 7 };
algo::Graph<int> g(vec);
g.setEdge(0, 1);
g.setEdge(0, 2);
g.setEdge(0, 3);
g.setEdge(0, 4);
g.setEdge(1, 5);
g.setEdge(2, 6);
g.se... | 541 | C++ | .cpp | 28 | 16.714286 | 59 | 0.592157 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,870 | bfsDemo.cpp | mandliya_algorithms_and_data_structures/graph_problems/bfsDemo.cpp | #include <iostream>
#include "graph.h"
/**
* Implementation of BFS algorithm is in ../include/graph.h
*/
int main()
{
std::vector<int> vec{ 0, 1, 2, 3, 4, 5, 6, 7 };
algo::Graph<int> g(vec);
g.setEdge(0, 1);
g.setEdge(0, 2);
g.setEdge(1, 0);
g.setEdge(1, 2);
g.setEdge(1, 3);
g.setEdge(2, 4);
g.set... | 523 | C++ | .cpp | 27 | 16.814815 | 59 | 0.595142 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,872 | pstring.cpp | mandliya_algorithms_and_data_structures/include/pstring.cpp | /**
* A string library for practice
* Ravi Mandliya
*/
#include "pstring.h"
using String = algo::String;
String::String( ) {
_reset();
}
String::String( const char * s ) {
_copy_str(s);
}
String::String( const String & str ) {
_copy_str(str);
}
String::String( String && other ) noexcept {
_reset();
... | 5,780 | C++ | .cpp | 235 | 21.587234 | 86 | 0.580926 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,873 | reverse_vowels.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/reverse_vowels.cpp | /*
* Write a function that takes a string as input and reverse only the vowels of a string.
*
* Example 1:
* Given s = "hello", return "holle".
*
* Example 2:
* Given s = "leetcode", return "leotcede".
*
* Note:
* The vowels does not include the letter "y".
*/
#include <iostream>
#include <algorithm>
bool ... | 1,220 | C++ | .cpp | 57 | 15.210526 | 89 | 0.449378 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,874 | moveZeroes.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/moveZeroes.cpp | /**
* Given an array nums, write a function to move all 0's to the end of it while maintaining the relative order of the non-zero elements.
* For example, given nums = [0, 1, 0, 3, 12], after calling your function, nums should be [1, 3, 12, 0, 0].
*
* Approach: start putting all non zero elements from at the start,... | 924 | C++ | .cpp | 34 | 25.147059 | 136 | 0.628668 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,875 | remove_element.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/remove_element.cpp | /*
* Source LeetCode Problem 27 Remove element.
* Given an array and a value, remove all instances of that value in-place and return the new length.
* Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
* The order of elements can be chan... | 1,458 | C++ | .cpp | 42 | 29.738095 | 129 | 0.616915 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,876 | maxProfitStock.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/maxProfitStock.cpp | /**
* Say you have an array for which the ith element is the price of a given stock on day i.
* If you were only permitted to complete at most one transaction (ie, buy one and sell one share of the stock),
* Design an algorithm to find the maximum profit.
*/
#include <iostream>
#include <vector>
int maxProfit(std... | 1,102 | C++ | .cpp | 41 | 24.658537 | 112 | 0.63327 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,878 | connectNextPointers.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/connectNextPointers.cpp | /**
* Populate each next pointer to point to its next right node. If there is no next right node, the next pointer should be set to NULL.
*
* Initially, all next pointers are set to NULL.
*
* Note:
*
* You may only use constant extra space.
* You may assume that it is a perfect binary tree (ie, all leaves are a... | 1,857 | C++ | .cpp | 77 | 21.662338 | 134 | 0.65031 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,879 | containsDuplicate.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/containsDuplicate.cpp | /**
* Given an array of integers, find if the array contains any duplicates.
* Your function should return true if any value appears at least twice in the array,
* and it should return false if every element is distinct.
*
* Approach : sort and check for adjacent elements for duplicates.
*
*/
#include <iostrea... | 1,000 | C++ | .cpp | 37 | 24.945946 | 85 | 0.652038 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,880 | median_stream.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/median_stream.cpp | /*
* Source : Leetcode, 295. Find Median from Data Stream
* Category : hard
*
* Find median from a data stream. Design a data structure that supports addNum to add a number to the stream,
* and findMedian to return the median of the current numbers seen so far. Also, if the count of numbers is
* even, return av... | 4,797 | C++ | .cpp | 124 | 33.596774 | 110 | 0.660864 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,881 | hamming_distance.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/hamming_distance.cpp | /**
The Hamming distance between two integers is the number of positions at which
the corresponding bits are different.
Given two integers x and y, calculate the Hamming distance.
Input: x = 1, y = 4
Output: 2
Explanation:
1 (0 0 0 1)
4 (0 1 0 0)
↑ ↑
The above arrows point to position... | 870 | C++ | .cpp | 33 | 21.30303 | 79 | 0.588957 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,882 | intersection_of_array.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/intersection_of_array.cpp | /*
* Find intersection of two arrays/vectors:
* Given two vectors find the result of their interaction.
* The result should only contain unique characters and can be in any order.
*
* [1 2 3 3 4 4 5 5]
* [2 3 5 5 4 4 6]
* Result: [2 3 5 4] or [2 3 4 5]
*/
#include <iostream>
#include <vector>
#include <unord... | 1,160 | C++ | .cpp | 44 | 22.522727 | 76 | 0.598383 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,884 | longestConsecutiveSeq.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/longestConsecutiveSeq.cpp | /**
* Leet code problem:
* Given an unsorted array of integers, find the length of the longest consecutive elements sequence.
* For example,
* Given [100, 4, 200, 1, 3, 2],
* The longest consecutive elements sequence is [1, 2, 3, 4]. Return its length: 4.
*/
#include <iostream>
#include <vector>
#include <unord... | 1,126 | C++ | .cpp | 46 | 22.086957 | 101 | 0.609302 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,885 | remove_duplicates.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/remove_duplicates.cpp | /*
* Given a sorted array, remove duplicates in place and return the new length.
* It doesn't matter what is in array beyond the unique elements size.
* Expected O(1) space and O(n) time complexity.
* Input : {1, 1, 2, 2, 3, 4, 4, 4, 5, 5, 6, 7, 7}
* Output: {1, 2, 3, 4, 5, 6, 7}
*/
#include <iostream>
... | 1,195 | C++ | .cpp | 43 | 23 | 79 | 0.549518 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,886 | sortCharByFrequency.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/sortCharByFrequency.cpp | /*
* Given a string, sort it in decreasing order based on the frequency of characters.
* Example:
* Input: cccbbbbaa
* Output: bbbcccaa
*
* Input: AaaBBaa
* Output: aaaaBBA
*
* Input: cccaaa
* Output:cccaaa or aaaccc
*
* Notice that order of chars in alphabatical order does not matter for same frequency ... | 1,731 | C++ | .cpp | 50 | 28.46 | 96 | 0.627119 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,887 | sumRootToLeafNumbers.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/sumRootToLeafNumbers.cpp | /**
*
* Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.
*
* An example is the root-to-leaf path 1->2->3 which represents the number 123.
*
* Find the total sum of all root-to-leaf numbers.
*
* For example,
*
* 1
* / \
* 2 3
* The roo... | 1,499 | C++ | .cpp | 60 | 22.966667 | 104 | 0.637762 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,888 | find_min_rotated.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/find_min_rotated.cpp | /**
* Find Minimum in Rotated Sorted Array
* Suppose a sorted array is rotated at some pivot unknown to you beforehand.
*
* (i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2).
*
* Find the minimum element.
*
* You may assume no duplicate exists in the array.
*/
#include <iostream>
#include <vector>
int findMin... | 805 | C++ | .cpp | 36 | 20.333333 | 77 | 0.581699 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,889 | editDistance.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/editDistance.cpp | /**
* Given two words word1 and word2, find the minimum number of steps required to convert word1 to word2. (each operation is counted as 1 step.)
*
* You have the following 3 operations permitted on a word:
*
* a) Insert a character
* b) Delete a character
* c) Replace a character
*
*/
#include <iostream>
#i... | 1,388 | C++ | .cpp | 55 | 22.781818 | 143 | 0.585219 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,890 | best_time_to_buy_sell.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/best_time_to_buy_sell.cpp | /*
* You are provided a vector of numbers, where each number represents
* price of a stock on ith day. If you are permitted to only complete
* one transaction per day (i.e buy one and sell one stock), design
* an algorithm to find the maximum profit.
*
* Input: [7, 1, 5, 3, 6, 4]
* Output: 5
* max. difference... | 1,487 | C++ | .cpp | 49 | 26.326531 | 74 | 0.616457 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,891 | word_pattern.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/word_pattern.cpp | /*
*
* Given a pattern and a string str, find if str follows the same pattern.
* Here follow means a full match, such that there is a bijection between a letter in pattern and a non-empty word in str.
* Examples:
* pattern = "abba", str = "dog cat cat dog" should return true.
* pattern = "abba", str = "dog cat ca... | 2,587 | C++ | .cpp | 69 | 31.623188 | 122 | 0.601513 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,893 | generate_parenthesis.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/generate_parenthesis.cpp | /**
* Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
*
* For example, given n = 3, a solution set is:
*
* "((()))", "(()())", "(())()", "()(())", "()()()"
*
*/
#include <iostream>
#include <vector>
#include <string>
void generate_parenthesis_helper( int... | 1,007 | C++ | .cpp | 36 | 25.833333 | 117 | 0.619048 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,894 | merge_trees.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/merge_trees.cpp | /*
Given two binary trees and imagine that when you put one of them to cover the other, some nodes
of the two trees are overlapped while the others are not.
You need to merge them into a new binary tree. The merge rule is that if two nodes overlap, then
sum node values up as the new value of the merged node.
Oth... | 2,326 | C++ | .cpp | 90 | 17.677778 | 97 | 0.432384 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,895 | remove_invalid_parenthesis.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/remove_invalid_parenthesis.cpp | /*
* Remove the minimum number of invalid parentheses in order to make the input string valid.
* Return all possible results.
* Note: The input string may contain letters other than the parentheses ( and ).
*
* Source: Leetcode, 301. Remove Invalid Parentheses
*
* solution approach:
*
* We can solve this pr... | 3,333 | C++ | .cpp | 98 | 29.204082 | 104 | 0.611699 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,896 | excelColSheetTitle.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/excelColSheetTitle.cpp | /**
* Given a positive integer, return its corresponding column title as appear in an Excel sheet.
*
* For example:
*
* 1 -> A
* 2 -> B
* 3 -> C
* ...
* 26 -> Z
* 27 -> AA
* 28 -> AB
*
* Approach:
* We need to convert the column value to effective a base 26 number, Imagine t... | 1,151 | C++ | .cpp | 47 | 22.276596 | 96 | 0.613079 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,897 | count_islands.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/count_islands.cpp | /*
* In a given 2D grid, 1 represents land and 0 represents water body.
* We need to count number of islands.
* An island is surrounded by connecting neighbouring lands vertically
* or horizontally.
* Assume: That everything around the grid is water.
*
* Approach: We can solve this problem with Depth/Breadth fi... | 2,323 | C++ | .cpp | 84 | 22.654762 | 76 | 0.529333 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,898 | jumpGame.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/jumpGame.cpp | /**
* Given an array of non-negative integers, you are initially positioned at the first index of the array.
*
* Each element in the array represents your maximum jump length at that position.
*
* Determine if you are able to reach the last index.
*
* For example:
* A = [2,3,1,1,4], return true.
*
* A = [3,2,... | 1,504 | C++ | .cpp | 54 | 25.685185 | 148 | 0.632089 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,899 | firstMissingPositiveNum.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/firstMissingPositiveNum.cpp | /**
* Problem: Given an unsorted integer array, find the first missing positive integer.
*
* For example,
* Given [1,2,0] return 3,
* and [3,4,-1,1] return 2.
*
* Your algorithm should run in O(n) time and uses constant space.
*
* Approach :
* Step 1 :Iterate through array and :
* - Ignore non positive nu... | 2,180 | C++ | .cpp | 65 | 31.430769 | 137 | 0.631829 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,901 | rotateList.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/rotateList.cpp | /**
* Given a list, rotate the list to the right by k places, where k is non-negative.
* For example:
* Given 1->2->3->4->5->NULL and k = 2,
* return 4->5->1->2->3->NULL
*/
#include <iostream>
struct ListNode {
int val;
ListNode * next;
ListNode(int x) : val(x), next(NULL) {}
};
void printList(ListNode * no... | 1,571 | C++ | .cpp | 80 | 17.45 | 83 | 0.615541 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,902 | maxArea.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/maxArea.cpp | /**
* Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai).
* n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0).
* Find two lines, which together with x-axis forms a container, such that the container contains the most water.
* No... | 1,080 | C++ | .cpp | 40 | 24.85 | 113 | 0.630309 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,903 | addDigits.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/addDigits.cpp | /**
* Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.
*
* For example:
*
* Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one digit, return it.
*
* Follow up:
* Could you do it without any loop/recursion in O(1) runtime?
*
* so... | 992 | C++ | .cpp | 36 | 25.527778 | 148 | 0.633018 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,904 | combinationSum3.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/combinationSum3.cpp | /**
* Find all possible combinations of k numbers that add up to a number n, given that only numbers from 1 to 9 can be used
* and each combination should be a unique set of numbers.
*
* Ensure that numbers within the set are sorted in ascending order.
* Example:
* Example 1:
*
* Input: k = 3, n = 7
*
* Outpu... | 1,458 | C++ | .cpp | 57 | 23.368421 | 121 | 0.614831 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,905 | missing_number.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/missing_number.cpp | /**
* Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one that is missing from the array.
*
* For example,
* Given nums = [0, 1, 3] return 2.
*/
#include <iostream>
#include <vector>
int missingNumber( std::vector<int>& nums ) {
int missing_sum = 0;
for ( auto n : nums ) {
m... | 834 | C++ | .cpp | 35 | 21.857143 | 120 | 0.598742 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,906 | summary_ranges.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/summary_ranges.cpp | /*
* Leet code problem - summary pages
* Given a sorted integer array without duplicates, return the summary of its ranges.
* For example, given [0,1,2,4,5,7], return ["0->2","4->5","7"].
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
std::vector<std::string> summaryRanges(std::ve... | 1,628 | C++ | .cpp | 53 | 22.867925 | 85 | 0.495541 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,907 | threeSumClosest.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/threeSumClosest.cpp | /**
* Given an array S of n integers, find three integers in S such that the sum is closest to a given number, target.
* Return the sum of the three integers. You may assume that each input would have exactly one solution.
* For example, given array S = {-1 2 1 -4}, and target = 1.
* The sum that is closest to the ... | 1,233 | C++ | .cpp | 42 | 26.642857 | 115 | 0.60371 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,908 | minPath.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/minPath.cpp | /**
* Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which minimizes the sum of all numbers along its path.
*
* Note: You can only move either down or right at any point in time.
*
* Can we do it in O(1) space complexity?
*/
#include <iostream>
#include <vector>
#i... | 1,172 | C++ | .cpp | 42 | 24.857143 | 152 | 0.549734 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,909 | shortest_path_maze.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/shortest_path_maze.cpp | /*
* Given a matrix with cell values 0 or 1. Find the length of the shortest path from (a1, b1)
* to (a2, b2), such that:
* Path can only be constructed through cells which have value 1.
* You can only travel in 4 possible directions, i.e. left, right, up and down.
*
* For example: Given matrix:
* Input:
... | 4,405 | C++ | .cpp | 125 | 28.048 | 94 | 0.487972 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,910 | product_except_self.cpp | mandliya_algorithms_and_data_structures/leet_code_problems/product_except_self.cpp | /*
* Given an array of n integers where n > 1, nums, return an array output
* such that output[i] is equal to the product of all the elements of nums except nums[i].
* Example: [1, 2, 3, 4] ==> [24, 12, 8, 6]
*
* Try to use constant space. (excluding result array)
*/
#include <iostream>
#include <vector>
/*
... | 1,385 | C++ | .cpp | 46 | 26.434783 | 90 | 0.635682 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,911 | find_odd_one_out.cpp | mandliya_algorithms_and_data_structures/bit_manipulation/find_odd_one_out.cpp | /**
* Given a vector of numbers, only one number occurs odd number of times, find the number
* Example - { 1, 1, 2, 2, 2, 2, 3, 3, 3} ==> Answer 3
* Approach - XOR of number with itself is 0, so even numbers will cancel out
* and we will be left with odd number.
*/
#include <iostream>
#include <vector>
int f... | 873 | C++ | .cpp | 33 | 23.787879 | 90 | 0.599282 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | true | false |
25,912 | check_opposite_signs.cpp | mandliya_algorithms_and_data_structures/bit_manipulation/check_opposite_signs.cpp | /*
* Given two integers, using bit manipulations determine if they are of opposite signs.
* Most Significant Bit (MSB) of number represents sign of the number. If it is 1, it represents
* a negative value, if it is 0, it represents a positive value.
* If MSB of two numbers are different, their XOR would be 1, other... | 1,104 | C++ | .cpp | 32 | 30.375 | 96 | 0.625234 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | true | true | true | false |
25,913 | multiply_by_7.cpp | mandliya_algorithms_and_data_structures/bit_manipulation/multiply_by_7.cpp | /**
* Problem : Muliply a number by 7 by using bit manipulation.
* Approach : left shift n by 3 --> 8n
* Therefore 7n = 8n - n;
*/
#include <iostream>
int multiply_by_7( int number )
{
return ((number << 3) - number);
}
int main()
{
std::cout << "Enter a number:";
int num;
std::cin >> num;
std::cout << ... | 405 | C++ | .cpp | 19 | 18.736842 | 61 | 0.575521 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,915 | addBin.cpp | mandliya_algorithms_and_data_structures/bit_manipulation/addBin.cpp | /*
* Add two binary numbers represented as string.
*
*/
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
std::string addBinary( const std::string & str1, const std::string & str2 )
{
std::string s1 = ( str1.length() > str2.length() ? str1 : str2 );
std::string s2 = ( str1.length... | 1,313 | C++ | .cpp | 52 | 19.538462 | 108 | 0.482484 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | true | false |
25,917 | reverseBitsOfAnInteger.cpp | mandliya_algorithms_and_data_structures/bit_manipulation/reverseBitsOfAnInteger.cpp | /**
* Problem : Reverse bits of an unsigned integer
*/
#include <iostream>
#include <sstream>
#include <cassert>
#include <algorithm>
/**
* swapBits - utility function to swap bits at position i and j in unsigned int x
* l represents bit at position i
* r represents bit at position j
* if l and r are same noth... | 6,026 | C++ | .cpp | 171 | 32.818713 | 81 | 0.572357 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,918 | check_if_power_of_4.cpp | mandliya_algorithms_and_data_structures/bit_manipulation/check_if_power_of_4.cpp | /*
* Check if a given number is power of 4 or not.
*
* Approach: If a value is power of 4, it has to be power of 2 and
* it will have set bits at even position (as the number is power of 2, it will have
* only one set bit.) For example:
* 4 (0100)
* 16 (0001 0000)
* 64 (0100 0000)
* If a number is po... | 1,497 | C++ | .cpp | 41 | 31.536585 | 86 | 0.604138 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,919 | next_power_of_2.cpp | mandliya_algorithms_and_data_structures/bit_manipulation/next_power_of_2.cpp | /*
* Write a function that, for a given no n, finds a number p which is greater than or equal to n and is a power of 2.
*/
#include <iostream>
int next_power_of_2( int num ) {
//already a power of 2
if (num && !(num & (num-1))) {
return num;
}
//count till msb set bit
int count = 0;
while... | 637 | C++ | .cpp | 26 | 20.346154 | 118 | 0.553542 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | true | true | true | false |
25,920 | swapBits.cpp | mandliya_algorithms_and_data_structures/bit_manipulation/swapBits.cpp | #include <iostream>
#include <bitset>
int swapBits(int n, int p, int q)
{
if (p == q)
{
return n;
}
// If bits are same, no point swapping.
// Determine if bits are different
//
if (((n & (1 << p)) >> p) ^ ((n & (1 << q)) >> q))
{
// toggle bits at p and q ... | 952 | C++ | .cpp | 36 | 20.333333 | 94 | 0.434687 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,921 | counter_game.cpp | mandliya_algorithms_and_data_structures/bit_manipulation/counter_game.cpp |
/*
Louise and Richard play a game. They have a counter set to N. Louise gets the first turn and the turns alternate thereafter. In the game, they perform the following operations.
If N is not a power of 2, reduce the counter by the largest power of 2 less than N.
If N is a power of 2, reduce the counter by half of N.... | 1,938 | C++ | .cpp | 65 | 24.138462 | 176 | 0.583514 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,922 | power_of_2.cpp | mandliya_algorithms_and_data_structures/bit_manipulation/power_of_2.cpp | /*
* Given a number, determine if its power of 2 using bit manipulation in O(1)
*/
#include <iostream>
bool powerOfTwo( int n )
{
return (n > 0 && !( n & ( n - 1 ) ));
}
int main()
{
int n;
std::cout << "Enter a number :";
std::cin >> n;
if ( powerOfTwo(n) ) {
std::cout << n << " is po... | 418 | C++ | .cpp | 20 | 17.25 | 77 | 0.516456 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | true | false |
25,923 | addition_without_operators.cpp | mandliya_algorithms_and_data_structures/bit_manipulation/addition_without_operators.cpp | /**
* Addtion of two numbers without using any arithmatic operators.
*/
#include <iostream>
int sum( int x, int y ) {
int carry = 0;
while( y != 0 ) {
//if x and y don't have same bits at same position, XOR of x and y
//gives us sum of x and y at those positions.
// bits wont change at positions con... | 1,175 | C++ | .cpp | 40 | 25.825 | 79 | 0.573828 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,925 | right_most_set_bit.cpp | mandliya_algorithms_and_data_structures/bit_manipulation/right_most_set_bit.cpp | /**
* Problem : One line function to return the position of right most bit.
* Approach : take 2's compliment and it with number.
* And finally taking a log of 2 + 1 will give us the position
*/
#include <iostream>
#include <cmath>
int position_of_first_set_bit( int num )
{
return log2(num & -num) + 1;
}
in... | 582 | C++ | .cpp | 21 | 24.571429 | 78 | 0.638489 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | true | true | true | false |
25,926 | swapSetOfBits.cpp | mandliya_algorithms_and_data_structures/bit_manipulation/swapSetOfBits.cpp | /**
* Problem - Given a number 'num' and two positions (p1 and p2 from right side) in binary representation of num,
* write a function that swaps n bits at given two positions and returns the result.
* It is also given that the two sets of bits do not overlap.
*/
#include <iostream>
int swapBits(unsigned int nu... | 1,977 | C++ | .cpp | 38 | 47.684211 | 112 | 0.645262 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | true | false |
25,927 | countNumberOfBitFlips.cpp | mandliya_algorithms_and_data_structures/bit_manipulation/countNumberOfBitFlips.cpp | /**
* Given two numbers A and B, count number of flips required to convert number A to B
* Approach : Take XOR of A and B, the result will contain set bits only at positions
* where A differed B. Therefore number of set bits in the result of A ^ B is the number
* of flips required to convert A to B
*/
#includ... | 790 | C++ | .cpp | 31 | 22.774194 | 89 | 0.617219 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | true | false |
25,928 | reverseEndianness.cpp | mandliya_algorithms_and_data_structures/bit_manipulation/reverseEndianness.cpp | #include <iostream>
#include <cstdio>
enum endianess {
LITTLE_ENDIAN_MACHINE = 0,
BIG_ENDIAN_MACHINE
};
endianess determine_endianess()
{
unsigned int num = 1;
char * c = (char *) #
if (*c == 1) {
return LITTLE_ENDIAN_MACHINE;
} else {
return BIG_ENDIAN_MACHINE;
}
}
void ... | 1,720 | C++ | .cpp | 57 | 26.140351 | 72 | 0.591103 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | true | false |
25,929 | 1-2-edi5-reverseString.cpp | mandliya_algorithms_and_data_structures/cracking_the_coding_interview_problems/1-2-edi5-reverseString.cpp | /*
* Cracking the coding interview edition *5* old one
* 1.2 Reverse a string when you are a pass a null terminated C string.
*/
#include<iostream>
#include<cstring>
#include<generic.h>
void reverse1( char * str)
{
int len = std::strlen(str);
for ( int i = 0; i < len/2; ++i ) {
algo::swap( str[i]... | 837 | C++ | .cpp | 34 | 20.764706 | 72 | 0.572682 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,930 | 1-3-edi5-removeDuplicates.cpp | mandliya_algorithms_and_data_structures/cracking_the_coding_interview_problems/1-3-edi5-removeDuplicates.cpp | /*
* Cracking the coding interview, edition 5
* Problem 1.3
* Write an algorithm to remove duplicate chars from a string
*/
#include <iostream>
#include <cstring>
using std::string;
using std::cin;
using std::cout;
using std::endl;
/*
* Function - removeDuplicates1
* Args - A string
* Return - Arg str... | 7,246 | C++ | .cpp | 233 | 25.841202 | 108 | 0.556432 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,931 | 1-1-hasUniqueChars.cpp | mandliya_algorithms_and_data_structures/cracking_the_coding_interview_problems/1-1-hasUniqueChars.cpp | /*
* Cracking the coding interview, edition 6
* Problem 1.1
* Write an algorithm to determine whether a string has unique characters or not
* Can we do it without using additional data structures?
*/
#include <iostream>
#include <cstring>
/*
* Function hasUniqueChars1
* Args - std::string
* Output:: True if... | 2,297 | C++ | .cpp | 69 | 28.724638 | 98 | 0.606431 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
25,936 | 2-4-partition.cpp | mandliya_algorithms_and_data_structures/cracking_the_coding_interview_problems/2-4-partition.cpp | /**
* Cracking the coding interview edition 6
* Problem 2.4 Partition:
* Write code to partition linked list around a value x, such that
* nodes less than x come before all the nodes greater than or equal to x.
* If x is in the list, the values of x only need to be after the elements less
* than x.
* Exam... | 2,535 | C++ | .cpp | 97 | 23.257732 | 92 | 0.623302 | mandliya/algorithms_and_data_structures | 5,894 | 1,319 | 168 | GPL-2.0 | 9/20/2024, 9:26:25 PM (Europe/Amsterdam) | false | false | true | false | false | true | false | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.