-
Notifications
You must be signed in to change notification settings - Fork 384
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added all the missing files and changed the location of 00008.cpp fil…
…e to Daily Coding Problems section
- Loading branch information
jatin singhal
committed
Oct 3, 2018
1 parent
779b01f
commit 34f1b90
Showing
366 changed files
with
74,450 additions
and
0 deletions.
There are no files selected for viewing
19 changes: 19 additions & 0 deletions
19
Competitions/Skillenza/Need For Code_ August Awesomeness/Chain it Up!.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
t = int(raw_input().strip()) | ||
for i in xrange(t): | ||
data = raw_input().strip() | ||
if len(data) > 0 and data[0] == '*': | ||
c = 0 | ||
for i in xrange(1, len(data)): | ||
if data[i] == '-': | ||
c += 1 | ||
elif data[i] == '*' and c > 0: | ||
c -= 1 | ||
else: | ||
c += 1 | ||
break | ||
if c == 0: | ||
print "Strong" | ||
else: | ||
print "Not Strong" | ||
else: | ||
print "Not Strong" |
Empty file.
10 changes: 10 additions & 0 deletions
10
Competitions/TechGig/Virtual Campus League 2017/Problem 1.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
def possibleways(input1): | ||
sum = 0 | ||
for i in input1: | ||
sum += i | ||
ans = 0 | ||
for i in xrange(len(input1)): | ||
ans += (i + 1) * sum * input1[i] | ||
sum -= input1[i] | ||
ans %= 10 ** 9 + 7 | ||
return ans |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
class Robofactory { | ||
public : | ||
int reveal(int[] query, string[] answer){ | ||
long long int | ||
} | ||
}; | ||
int main(){ | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
class Initials { | ||
public : string getInitials(string s){ | ||
string c=""; | ||
c.push_back(s[0]); | ||
for(int i=1;i<s.length();i++){ | ||
if(s[i]==' '){ | ||
c.push_back(s[i+1]); | ||
} | ||
} | ||
return c; | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
class RepeatStringEasy { | ||
public : int maximalLength(string s){ | ||
int i, ans; | ||
ans=0; | ||
string s1, s2; | ||
for(i=s.length()/2;i>0;i--){ | ||
s1=s.substr(0, i-1); | ||
s2=s.substr(i, s.length()-i-1); | ||
if(s1.find(s2)!=std::string::npos){ | ||
ans=s1.length(); | ||
break; | ||
} | ||
} | ||
ans=ans*2; | ||
return ans; | ||
} | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
class AlternatingString { | ||
public : | ||
int maxLength(string s){ | ||
int ans, temp, i; | ||
if(s.length()==1){ | ||
ans = 1; | ||
} | ||
else { | ||
temp=1; | ||
ans=0; | ||
for(i=0;i<s.length()-1;i++){ | ||
if(s[i]!=s[i+1]){ | ||
temp++; | ||
} | ||
else{ | ||
temp=1; | ||
} | ||
if(ans<temp){ | ||
ans = temp; | ||
} | ||
} | ||
} | ||
return ans; | ||
} | ||
}; | ||
int main(){ | ||
AlternatingString A; | ||
cout<<A.maxLength("111101111")<<endl; | ||
cout<<A.maxLength("1010101")<<endl; | ||
cout<<A.maxLength("000011110000")<<endl; | ||
cout<<A.maxLength("1011011110101010010101")<<endl; | ||
cout<<A.maxLength("0")<<endl; | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
class GCDGraph { | ||
public : String possible(int n, int k, int x, int y){ | ||
|
||
} | ||
}; | ||
int main(){ | ||
GCDGraph A; | ||
cout<<A.possible(12, 2, 8, 9)<<endl; | ||
cout<<A.possible(12, 2, 11, 12)<<endl; | ||
cout<<A.possible(12, 2, 11, 11)<<endl; | ||
cout<<A.possible(10, 2, 8, 9)<<endl; | ||
cout<<A.possible(1000000, 1000, 12345, 54321)<<endl; | ||
cout<<A.possible(1000000, 2000, 12345, 54321)<<endl; | ||
cout<<A.possible(2, 0, 1, 2)<<endl; | ||
} |
3 changes: 3 additions & 0 deletions
3
Competitions/TopCoder/TCO17 India Regionals Event/Submission.txt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
manishbisht | ||
2555617 | ||
310e10c2e2fbfd9f4a37c8683ffa292adb816d5a5ca9f6bcb3a2eedb50fed84c |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from random import randint | ||
import hashlib | ||
|
||
my_topcoder_handle = 'manishbisht' | ||
random_number = randint(0, 10000000) | ||
text = my_topcoder_handle + str(random_number) | ||
print my_topcoder_handle | ||
print random_number | ||
print hashlib.sha256(text).hexdigest() | ||
|
130 changes: 130 additions & 0 deletions
130
Data Structures/04 Linked List/01 Singly Linked List.py
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
# Node class | ||
class Node: | ||
# Constructor | ||
def __init__(self): | ||
self.data = None | ||
self.next = None | ||
|
||
# Set the data in the Node | ||
def set_data(self, data): | ||
self.data = data | ||
|
||
# Return the data of the Node | ||
def get_data(self): | ||
return self.data | ||
|
||
# Set the next value of the Node | ||
def set_next(self, next): | ||
self.next = next | ||
|
||
# Return the next value of the Node | ||
def get_next(self): | ||
return self.next | ||
|
||
# Check if the Node has the next value | ||
def has_next(self): | ||
return self.next is not None | ||
|
||
|
||
# Singly LinkedList class | ||
class SinglyLinkedList: | ||
# Constructor | ||
def __init__(self): | ||
self.head = None | ||
|
||
# Insert a new node in the LinkedList | ||
def list_insert(self, position, data): | ||
length_of_list = self.list_length() | ||
if position > length_of_list or position < 0: | ||
return None | ||
elif position == 0: | ||
self.insert_at_start(data) | ||
elif position == length_of_list: | ||
self.insert_at_end(data) | ||
else: | ||
new_node = Node() | ||
new_node.set_data(data) | ||
current = self.head | ||
count = 0 | ||
|
||
while count < position - 1: | ||
current = current.get_next() | ||
count += 1 | ||
|
||
new_node.set_next(current.get_next()) | ||
current.set_next(new_node) | ||
|
||
# Insert a new node at the start of LinkedList | ||
def insert_at_start(self, data): | ||
new_node = Node() | ||
new_node.set_data(data) | ||
|
||
if self.list_length() == 0: | ||
self.head = new_node | ||
else: | ||
new_node.set_next(self.head) | ||
self.head = new_node | ||
|
||
# Insert a new node at the start of LinkedList | ||
def insert_at_end(self, data): | ||
new_node = Node() | ||
new_node.set_data(data) | ||
current = self.head | ||
|
||
while current.get_next() is not None: | ||
current = current.get_next() | ||
|
||
current.set_next(new_node) | ||
|
||
# Delete a node from the LinkedList by position | ||
def list_delete_position(self, position): | ||
if position > self.list_length() or position < 0: | ||
print 'Invalid Position' | ||
else: | ||
count = 0 | ||
current = self.head | ||
previous = self.head | ||
while current.get_next() is not None or count <= position: | ||
count += 1 | ||
if count == position: | ||
previous.set_next(current.get_next()) | ||
return | ||
else: | ||
previous = current | ||
current = current.get_next() | ||
|
||
# Return the length of the LinkedList | ||
def list_length(self): | ||
current = self.head | ||
count = 0 | ||
|
||
while current is not None: | ||
count += 1 | ||
current = current.get_next() | ||
|
||
return count | ||
|
||
# Print the LinkedList | ||
def print_list(self): | ||
current = self.head | ||
|
||
while current is not None: | ||
print current.get_data(), | ||
print '->', | ||
current = current.get_next() | ||
print 'End' | ||
|
||
# Delete the LinkedList | ||
def clear(self): | ||
self.head = None | ||
|
||
|
||
LinkedList = SinglyLinkedList() | ||
LinkedList.insert_at_start(5) | ||
LinkedList.print_list() | ||
LinkedList.insert_at_end(10) | ||
LinkedList.print_list() | ||
LinkedList.list_insert(1, 50) | ||
LinkedList.print_list() | ||
LinkedList.list_delete_position(2) | ||
LinkedList.print_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Introduction | ||
|
||
- A linkedlist is a collection of nodes that forms a linear sequence. | ||
- Each Node has 2 parts: Data and reference to next node. | ||
- Time Complexity: | ||
- Insert: `O(n)` | ||
- Delete: `O(n)` | ||
- Access: `O(n)` | ||
- Search: `O(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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# What is Tree ?\n", | ||
"It is a data structure similar to linked list but instead of pointing to one node it points to multiple nodes." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": { | ||
"collapsed": true | ||
}, | ||
"outputs": [], | ||
"source": [] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 2", | ||
"language": "python", | ||
"name": "python2" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 2 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython2", | ||
"version": "2.7.13" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |
Oops, something went wrong.