-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
214 changed files
with
0 additions
and
6,092 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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 |
---|---|---|
@@ -1,25 +0,0 @@ | ||
// UVa10550.cpp : This file contains the 'main' function. Program execution begins and ends there. | ||
// | ||
|
||
#include <iostream> | ||
#include <string> | ||
|
||
using namespace std; | ||
|
||
int main() | ||
{ | ||
// UVA 11172 - Relational Operator | ||
string line; | ||
int a, b, n; | ||
cin >> n; | ||
for (int i = 0; i < n; i++) | ||
{ | ||
cin >> a >> b; | ||
if (a < b) | ||
cout << "<" <<endl; | ||
else if (a > b) | ||
cout << ">" << endl; | ||
else | ||
cout << "=" << 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 |
---|---|---|
@@ -1,32 +0,0 @@ | ||
// Author: Davide pOLLICINO | ||
// Date: 05/01/2019 | ||
#include <iostream> | ||
#include<vector> | ||
using namespace std; | ||
|
||
int main() | ||
{ | ||
int n , foreman_element; | ||
vector<int> foremen_vector; | ||
cin >> n; | ||
cout << "Lumberjacks:"<< endl; | ||
for (int a = 0; a < n; i++) | ||
{ | ||
for (int i =0; i<10; i++) | ||
{ | ||
cin >> foreman_element; | ||
foremen_vector.push_back(foreman_element); | ||
} | ||
//Check here if sorter or not | ||
if(is_sorted(foremen_vector.begin(), foremen_vector.end())) | ||
{ | ||
cout <<"Ordered"<<endl; | ||
} | ||
else | ||
{ | ||
cout <<"Unordered" <<endl; | ||
} | ||
foremen_vector.clear(); | ||
} | ||
return 0; | ||
} | ||
Binary file not shown.
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 |
---|---|---|
@@ -1,28 +0,0 @@ | ||
#include<bits/stdc++.h> | ||
using namespace std; | ||
|
||
// This approach has O(N^2) complexity | ||
void subArray(int arr[], int n) | ||
{ | ||
for(int i =0; i < n; i++) | ||
{ | ||
for(int j=i; j < n; j++) | ||
{ | ||
for(int k=i; k <=j; k++) | ||
{ | ||
cout<<arr[k]<<" "; | ||
} | ||
cout<<endl; | ||
} | ||
} | ||
} | ||
|
||
int main() | ||
{ | ||
int arr[] = {1,2,3,4,6}; | ||
int n = sizeof(arr)/sizeof(arr[0]); | ||
cout << "Now printing all non-empty subarrays"<<endl; | ||
subArray(arr, n); | ||
|
||
return 0; | ||
} | ||
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 |
---|---|---|
@@ -1,74 +0,0 @@ | ||
#include<bits/stdc++.h> | ||
|
||
using namespace std; | ||
vector<vector<int>>all_subarrays; | ||
|
||
|
||
|
||
void generate_subarrays(int arr[], int n) | ||
{ | ||
|
||
vector<int>temp; | ||
for(int i =0; i< n; i++) | ||
{ | ||
for(int j=i; j < n; j++) | ||
{ | ||
for(int k = i; k <=j; k++) | ||
{ | ||
temp.push_back(arr[k]); | ||
} | ||
all_subarrays.push_back(temp); | ||
temp.clear(); | ||
} | ||
} | ||
|
||
|
||
// Print all generated subarrays | ||
for(int i =0; i < all_subarrays.size(); i++) | ||
{ | ||
for(int j=0; j < all_subarrays[i].size(); j++) | ||
{ | ||
cout << all_subarrays[i][j] <<" "; | ||
|
||
} | ||
cout <<endl; | ||
} | ||
} | ||
|
||
|
||
/* | ||
In how many subarrays it is the smallest | ||
*/ | ||
int in_how_many_is_the_smallest(int number) | ||
{ | ||
int solution = 0; | ||
int smallest; | ||
for(int i =0; i < all_subarrays.size(); i++) | ||
{ | ||
smallest = INT_MAX; | ||
for(int j=0; j < all_subarrays[i].size(); j++) | ||
{ | ||
if(smallest > all_subarrays[i][j]) | ||
smallest = all_subarrays[i][j]; | ||
} | ||
if(smallest == number) | ||
solution += 1; | ||
} | ||
|
||
return solution; | ||
} | ||
|
||
int main() | ||
{ | ||
int arr[] = {1,2,3,4,6}; | ||
int n = sizeof(arr)/ sizeof(arr[0]); | ||
|
||
generate_subarrays(arr, n); | ||
|
||
cout << "--Smallest in how many subarrays" <<endl; | ||
|
||
for(int i =0; i < n; i++) | ||
cout<<arr[i] << " :" << in_how_many_is_the_smallest(arr[i]) << endl; | ||
|
||
return 0; | ||
} | ||
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 |
---|---|---|
@@ -1,29 +0,0 @@ | ||
// Source: GeeksForGeeks | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int arr[] = {-2,3,4,-2-7,3,1,-9}; | ||
int n = sizeof(arr)/sizeof(arr[0]); | ||
|
||
void print_array() | ||
{ | ||
for(int i =0; i < n; i++) | ||
cout << arr[i] << " "; | ||
cout <<endl; | ||
} | ||
|
||
int main() | ||
{ | ||
int max_so_far = 0; | ||
int max_ending_here = 0; | ||
print_array(); | ||
for(int i=0; i < n; i++) | ||
{ | ||
max_ending_here += arr[i]; | ||
if(max_ending_here < 0) | ||
max_ending_here = 0; | ||
if(max_so_far < max_ending_here) | ||
max_so_far = max_ending_here; | ||
} | ||
cout <<max_so_far<<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 |
---|---|---|
@@ -1,33 +0,0 @@ | ||
// Source: GeeksForGeeks | ||
#include <iostream> | ||
#include <math.h> | ||
#include<algorithm> | ||
using namespace std; | ||
|
||
int arr[] = {-2,-3, -5, -1, -6, -9}; | ||
int n = sizeof(arr)/sizeof(arr[0]); | ||
|
||
void print_array() | ||
{ | ||
for(int i =0; i < n; i++) | ||
cout << arr[i] << " "; | ||
cout <<endl; | ||
} | ||
|
||
int main() | ||
{ | ||
int current_max = arr[0]; | ||
int biggest = arr[0]; | ||
print_array(); | ||
for(int i=1; i < n; i++) | ||
{ | ||
|
||
current_max = max(arr current_max+__is_array_known_bounds[i]); | ||
biggest = max(biggest, current_max); | ||
|
||
} | ||
cout << biggest <<endl; | ||
return 0; | ||
} | ||
|
||
|
||
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 |
---|---|---|
@@ -1,8 +0,0 @@ | ||
# Codebyte Solutions | ||
|
||
|
||
|Challenge Name|SolUtion| | ||
|-------|:------:| | ||
|Longest Word|[Java](longest_word/longest_word.java)| | ||
|Prime factorial|[Java](prime_factorial/prime_factorial.java)| | ||
|Reverse|[Java](reverse/reverse.java)| | ||
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 |
---|---|---|
@@ -1,21 +0,0 @@ | ||
import java.util.*; | ||
import java.io.*; | ||
|
||
class Main { | ||
public static String LongestWord(String sen) { | ||
String[] words = sen.toLowerCase().split("[^A-Za-z]"); | ||
int maxIndex = 0; | ||
for (int i = 1; i < words.length; i++) { | ||
if (words[i].length() > words[maxIndex].length()) { | ||
maxIndex = i; | ||
} | ||
} | ||
return words[maxIndex]; | ||
} | ||
|
||
public static void main (String[] args) { | ||
// keep this function call here | ||
Scanner s = new Scanner(System.in); | ||
System.out.print(LongestWord(s.nextLine())); | ||
} | ||
} | ||
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 |
---|---|---|
@@ -1,19 +0,0 @@ | ||
import java.util.*; | ||
import java.io.*; | ||
|
||
class Main { | ||
|
||
public static String FirstReverse(String str) { | ||
// code goes he | ||
String result = ""; | ||
for(int i= str.length()-1; i >=0; i--) | ||
result += str.charAt(i); | ||
return result; | ||
} | ||
|
||
public static void main (String[] args) { | ||
// keep this function call here | ||
Scanner s = new Scanner(System.in); | ||
System.out.print(FirstReverse(s.nextLine())); | ||
} | ||
} | ||
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 |
---|---|---|
@@ -1,24 +0,0 @@ | ||
//https://www.codechef.com/submit/AMR15A | ||
#include <iostream> | ||
using namespace std; | ||
|
||
int main() { | ||
int t; | ||
cin >>t; | ||
|
||
int odd=0, even=0; | ||
int e; | ||
for(int i =0; i< t; i++) | ||
{ | ||
cin >> e; | ||
if(e%2 == 0) | ||
even++; | ||
else | ||
odd++; | ||
} | ||
if(even > odd) | ||
cout<<"READY FOR BATTLE"<<endl; | ||
else | ||
cout<<"NOT READY"<<endl; | ||
return 0; | ||
} | ||
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 |
---|---|---|
@@ -1,48 +0,0 @@ | ||
#include <iostream> | ||
#include <iomanip> | ||
using namespace std; | ||
// TO TEST, it gives error | ||
void test_case() | ||
{ | ||
unsigned int possible_withdraw = 4; | ||
double balance = 120.00; | ||
//cin >> possible_withdraw >> balance; | ||
cout.precision(2); | ||
if(possible_withdraw < 5) | ||
{ | ||
cout<<fixed << balance<<endl; | ||
return; | ||
} | ||
|
||
else if(possible_withdraw %5 != 0) | ||
{ | ||
cout<<fixed << balance<<endl; | ||
return; | ||
} | ||
else if(possible_withdraw >balance) | ||
{ | ||
cout << fixed << balance<<endl; | ||
return; | ||
} | ||
else | ||
{ | ||
balance -= possible_withdraw; | ||
balance -= 0.50; | ||
cout<< fixed << balance<<endl; | ||
|
||
|
||
} | ||
} | ||
|
||
int main() | ||
{ | ||
// number of test cases | ||
int t=1; | ||
// Read number of test cases | ||
//cin >>t; | ||
for(int i =0; i<t; i++) | ||
{ | ||
test_case(); | ||
} | ||
return 0; | ||
} | ||
Oops, something went wrong.