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 remove_duplicates(string) | |
write_index = 0 | |
for i in 0..string.length-1 | |
found = false | |
for j in 0..write_index-1 | |
if (string[i] == string[j]) | |
found = true | |
break |
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 remove_white_spaces(string) | |
if (!string || string.size == 0) | |
return | |
end | |
read_index = 0 | |
write_index = 0 | |
while (read_index < string.length) | |
if (string[read_index] != ' ' && string[read_index] != '\t') |
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
require 'set' | |
def segment_string(s, dictionary, solved) | |
for i in 1..s.length | |
first = s[0, i] | |
if dictionary.include?(first) | |
second = s[i .. -1] | |
if (second.length == 0) | |
return true | |
end |
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 find_palindromes_in_sub_string(input, j, k) | |
while (j >= 0 && k < input.length) | |
if (input[j] != input[k]) | |
break | |
end | |
puts (input[j .. k]) | |
j -= 1 | |
k += 1 | |
end | |
end |
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 sum(array) | |
sum = 0 | |
if array.size == 1 | |
sum += array[0] | |
return sum | |
else | |
array.shift | |
sum(array) | |
end | |
end |
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> | |
int main() | |
{ | |
printf("Hello World!"); | |
printf("\n"); | |
} |
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> | |
int main() | |
{ | |
int count; | |
count = 0; | |
while (count < 3) { | |
printf("%d\t\n", count); |
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> | |
int main() | |
{ | |
int count; | |
for(count = 0; count < 3; count++) { | |
printf("%d \n", count); | |
} | |
} |
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> | |
#define LOWER 0 | |
#define UPPER 3 | |
int main() | |
{ | |
int count; | |
for(count = 0; count <= 3; count++) { |
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> | |
int main() | |
{ | |
int count, i; | |
count = 0; | |
for(i = 1; i <= 3; i++) { | |
count += i; |