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
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] |
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
""" | |
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 |
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 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)): |
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 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("================================") |
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 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++) |
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 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); |
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> | |
void quicksort(int a[],int first,int last) | |
{ | |
int temp,pviot,i,j; | |
if (first<last) | |
{ | |
pviot = first; | |
i = first ; | |
j = last; |
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 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) | |
{ |
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
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] |
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 array [100]; | |
int maxi_index,j; | |
scanf("%d",&maxi_index); | |
array [maxi_index]; | |
for (j=0;j<maxi_index;j++) | |
scanf("%d",&array [j]); |
OlderNewer