Skip to content

Instantly share code, notes, and snippets.

View bparanj's full-sized avatar

Bala Paranj bparanj

View GitHub Profile
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
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')
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
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
def sum(array)
sum = 0
if array.size == 1
sum += array[0]
return sum
else
array.shift
sum(array)
end
end
#include <stdio.h>
int main()
{
printf("Hello World!");
printf("\n");
}
#include <stdio.h>
int main()
{
int count;
count = 0;
while (count < 3) {
printf("%d\t\n", count);
#include <stdio.h>
int main()
{
int count;
for(count = 0; count < 3; count++) {
printf("%d \n", count);
}
}
#include <stdio.h>
#define LOWER 0
#define UPPER 3
int main()
{
int count;
for(count = 0; count <= 3; count++) {
#include <stdio.h>
int main()
{
int count, i;
count = 0;
for(i = 1; i <= 3; i++) {
count += i;