This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cmath> | |
#include <cstdio> | |
#include <vector> | |
#include <iostream> | |
#include <algorithm> | |
using namespace std; | |
int main() { | |
/* Enter your code here. Read input from STDIN. Print output to STDOUT */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <cstdio> | |
#include <vector> | |
#include <iostream> | |
#include <string.h> | |
#include <map> | |
using namespace std; | |
int main() { | |
/* Enter your code here. Read input from STDIN. Print output to STDOUT */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string isValid(string s) { | |
std::map<char, int> freq; | |
vector<int> list; | |
vector<int> vals; | |
vector<int>::iterator list_unique; | |
if(s.length() == 1) return "YES"; | |
else | |
{ | |
for(int i = 0; i < s.length(); i++){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int alternatingCharacters(char* s) { | |
int c = 0; | |
char* AB = "AB"; | |
char* BA = "BA"; | |
char *ptr1 = strstr(s, AB); | |
char *ptr2 = strstr(s, AB); | |
if (ptr1 != NULL || ptr2 != NULL) | |
{ | |
for (int i = 0; i < strlen(s) - 1; i++) { | |
if (s[i] == s[i + 1]) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int Count(char* s, char c) { | |
// Count variable | |
int res = 0; | |
for (int i = 0; i < strlen(s); i++) | |
// checking character in string | |
if (s[i] == c) | |
res++; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <string.h> | |
#include <ctype.h> | |
int strcmpws(const char *s1, const char *s2) | |
{ | |
char *r1 = strdup(s1); | |
char *r2 = strdup(s2); | |
int f = 0; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def invert_endianness(number): | |
new_bits = [] | |
total_bits = number.bit_length() | |
check_len = True | |
bits = 8 | |
while(check_len): | |
if (bits - total_bits) >= 0: | |
check_len = False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def atoi(s): | |
integer = 0 | |
sign = 1 | |
s0 = s[0] | |
if s0 in '+-': | |
s = s[1:] | |
if s0 == '-': | |
sign = -1 | |
for d in s: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
min_max_sum_linked_list(): | |
“Walk a linked list (passed in as a parameter) and return a min, max, and average of the values at the end.” | |
Function returns min, max, and average only if linked list contains numbers with these conditions: int, long, float, positive, negative. | |
Average is returned in float to provide an accurate result | |
Test Suite: | |
Node class | |
LinkedList class with methods insert_tail(data) and monitoring() | |
genTestCases class with methods generateCustomTestCase(values), generateRandomTestCase(max_len, max_val), generateEqualValuesTestCase(max_len, val) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Test Suite: | |
Node class | |
LinkedList class with methods insert_tail(data) and monitoring() | |
genTestCases class with methods generateCustomTestCase(values), generateRandomTestCase(max_len, max_val), generateEqualValuesTestCase(max_len, val) | |
runTests(): | |
Custom your tests | |
DebugL1 will show the results of each TestCase | |
DebugL2 will show the linked list generated |
NewerOlder