Skip to content

Instantly share code, notes, and snippets.

View devils-ey3's full-sized avatar
🎯
Focusing

Yeahia Md Abid devils-ey3

🎯
Focusing
View GitHub Profile
@devils-ey3
devils-ey3 / longest_subString.py
Last active September 21, 2016 10:43
Write a program that prints the longest substring which the letters occur in alphabetical order.
si = ['azcbobobegghakl', 'abcdefghijklmnopqrstuvwxyz', 'nqlkcvjkwytg', 'bovgfeiromsncq']
for s in si:
max_subStr = ''
for i in range(len(s)):
sub_string = s[i]
char_count = 0
while i + 1 < len(s) and s[i]<=s[i+1]:
char_count+=1
i+=1
sub_string+=s[i]
@devils-ey3
devils-ey3 / quick_find_connectivity.py
Created September 21, 2016 10:57
quick find connectivity check algorithm demo
"""
Is a quick find connectivity check algorithm demo code.
I try to write it simply, hope you can understand it
"""
def give_index_value(a):
count = 0
id = {}
a = set(a) # for removing duplicates'
for i in a:
id[i]=count
@devils-ey3
devils-ey3 / parmutation.py
Created September 21, 2016 11:02
Parmutation algorithm by python 3x
def parmutation(list):
if len(list)==0:
return []
elif len(list)==1:
return [list]
else:
new_list = []
print("New list --> ",new_list,"Len newlist --> ",len(new_list))
print("Len before for loop -->",len(list))
for i in range(len(list)):
@devils-ey3
devils-ey3 / mergeSort.py
Created September 21, 2016 11:04
Merge Sort By python
def main():
a = []
for i in tuple(map(int,input("Enter the number : ").split(' '))):
a.append(i)
mergesSort(a)
print(a)
def mergesSort(a):
if len(a)>1:
print("================================")
@devils-ey3
devils-ey3 / selection.c
Created September 21, 2016 11:06
Selection sort by C
#include <stdio.h>
int main()
{
int size,array[100],i,j,temp=0;
printf("Enter the index number: ");
scanf("%d",&size);
printf("\ninsert the numbers into the array: ");
for(i=0; i<size; i++)
@devils-ey3
devils-ey3 / mergeSort.c
Created September 21, 2016 11:07
Merge sort by C
#include <stdio.h>
int main ()
{
int array [100],array1[100],main[100];
int maxi_index,j,maxi_index1;
scanf("%d",&maxi_index);
array [maxi_index];
for (j=0; j<maxi_index; j++)
scanf("%d",&array [j]);
scanf("%d",&maxi_index1);
@devils-ey3
devils-ey3 / quickSort.c
Created September 21, 2016 11:09
Quick sort by C
#include <stdio.h>
void quicksort(int a[],int first,int last)
{
int temp,pviot,i,j;
if (first<last)
{
pviot = first;
i = first ;
j = last;
@devils-ey3
devils-ey3 / queue.c
Created September 21, 2016 11:10
Easiest way to make a queue code by C. It has a bug but working properly
#include <stdio.h>
#define max 5
int rear=-1,front=-1,array[max];
void printInstruction()
{
printf("Press 1 for push\nPress 2 for pop\nPress 3 for display full list\nPress 4 for display top and last\nPress ctrl+z for exit\n\n");
}
void push(int j)
{
@devils-ey3
devils-ey3 / insertSort.py
Created September 21, 2016 11:12
Insert Sort code by python
a = []
i = (int) (input("How much element do you want : "))
for element in range(i):
a.append((int)(input("> ")))
for element in range(1,i):
j = element
while j > 0 and a[j] < a[j-1]:
a[j-1],a[j]=a[j],a[j-1]
@devils-ey3
devils-ey3 / delete.c
Created September 21, 2016 11:13
Delete a number from an array
#include <stdio.h>
int main ()
{
int array [100];
int maxi_index,j;
scanf("%d",&maxi_index);
array [maxi_index];
for (j=0;j<maxi_index;j++)
scanf("%d",&array [j]);