Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Blue Movement Boot Camp
# Blue Movement Boot Camp

## Getting Started

Expand Down
Binary file added week-2/C++/.vs/C++/v16/.suo
Binary file not shown.
Binary file added week-2/C++/.vs/C++/v16/Browse.VC.db
Binary file not shown.
Binary file not shown.
3 changes: 3 additions & 0 deletions week-2/C++/.vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": "x86-Debug"
}
6 changes: 6 additions & 0 deletions week-2/C++/.vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"ExpandedNodes": [
""
],
"PreviewInSolutionExplorer": false
}
Binary file added week-2/C++/.vs/slnx.sqlite
Binary file not shown.
21 changes: 21 additions & 0 deletions week-2/C++/CppProperties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"configurations": [
{
"inheritEnvironments": [
"msvc_x86"
],
"name": "x86-Debug",
"includePath": [
"${env.INCLUDE}",
"${workspaceRoot}\\**"
],
"defines": [
"WIN32",
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"intelliSenseMode": "windows-msvc-x86"
}
]
}
Empty file removed week-2/C++/main.cpp
Empty file.
53 changes: 53 additions & 0 deletions week-2/C++/spencer-webster-bass-q1.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#include <iostream>
#include <vector>

// using namespace std;

// inspired by DFS
void permutationsUtil(int depth, std::string& str, std::vector<bool> vis, std::vector<int> stk, std::vector<std::string>& acc)
{
int n = vis.size();

// leaf node
if (depth == n) {
std::string s = "";
for (int i : stk)
{
s.push_back(str.at(i));
}
acc.push_back(s);
} else {
for (int i = 0; i < n; ++i)
{
if (!vis[i])
{
stk.push_back(i);
vis[i] = true;
permutationsUtil(depth+1, str, vis, stk, acc);
vis[i] = false;
stk.pop_back();
}
}
}
}

std::vector<std::string> permutations(std::string str)
{
std::vector<bool> vis(str.size(), false);
std::vector<int> stk;
std::vector<std::string> acc;
permutationsUtil(0, str, vis, stk, acc);
return acc;
}

// look at saving space by using pointers and references especially with using the recurisve stack
// you can just print the solution instead of storing it
int main(int argc, char const *argv[]) {
std::cout << "Given a string str, the task is to print all the permutations of str. A permutation is an arrangement of all or part of a set of objects, with regard to the order of the arrangement. For example, if given abb, the output should be abb abb bab bba bab bba" << std::endl;

std::string input = "abb";
std::vector<std::string> output = permutations(input);

for (std::string o : output)
std::cout << o << std::endl;
}
63 changes: 63 additions & 0 deletions week-2/C++/spencer-webster-bass-q2.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#include <iostream>

// using namespace std;

// dynamic programming problem
std::string longPalSubstr(std::string str)
{
int n = str.length();
bool isPal[n][n];

int a, b = 0;

// i will be the starting index and j will be the ending index
for (int i = 0; i < n; i++)
{
for (int j = 0; j < n; j++)
{
if (i == j) {
// bsae case: m = 1
isPal[i][j] = true;
} else if (j - i == 1 && str[i] == str[j]) {
// bsae case: m = 2
isPal[i][j] = true;
a = i;
b = j;
} else {
isPal[i][j] = false;
}
}
}

if (n > 2)
{
// let m be the size of the substring
for (int m = 3; m <= n; m++)
{
int i = 0;
int j = m - 1;
while (j < n)
{
isPal[i][j] = (str[i] == str[j]) && isPal[i+1][j-1];
if (isPal[i][j] && m > b - a + 1)
{
a = i;
b = j;
}
i++;
j++;
}
}
}

return str.substr(a, b - a + 1);
}

int main(int argc, char const *argv[]) {
std::cout << "Given a string, find the longest substring which is palindrome. For example, if the given string is ababad, the output should be ababa." << std::endl << std::endl;

std::string input = "ababad";
std::string output = longPalSubstr(input);

std::cout << output << std::endl;
}
Binary file added week-3/C++/.vs/C++/v16/.suo
Binary file not shown.
Binary file added week-3/C++/.vs/C++/v16/Browse.VC.db
Binary file not shown.
Binary file not shown.
31 changes: 31 additions & 0 deletions week-3/C++/C++.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30128.74
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "C++", "C++\C++.vcxproj", "{31ED04FC-A57E-4B26-9A84-0FFB389B5A0C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{31ED04FC-A57E-4B26-9A84-0FFB389B5A0C}.Debug|x64.ActiveCfg = Debug|x64
{31ED04FC-A57E-4B26-9A84-0FFB389B5A0C}.Debug|x64.Build.0 = Debug|x64
{31ED04FC-A57E-4B26-9A84-0FFB389B5A0C}.Debug|x86.ActiveCfg = Debug|Win32
{31ED04FC-A57E-4B26-9A84-0FFB389B5A0C}.Debug|x86.Build.0 = Debug|Win32
{31ED04FC-A57E-4B26-9A84-0FFB389B5A0C}.Release|x64.ActiveCfg = Release|x64
{31ED04FC-A57E-4B26-9A84-0FFB389B5A0C}.Release|x64.Build.0 = Release|x64
{31ED04FC-A57E-4B26-9A84-0FFB389B5A0C}.Release|x86.ActiveCfg = Release|Win32
{31ED04FC-A57E-4B26-9A84-0FFB389B5A0C}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E405B9BE-B8D7-4647-96AE-D7E57AB66A58}
EndGlobalSection
EndGlobal
75 changes: 75 additions & 0 deletions week-3/C++/C++/C++.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
// C++.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include <vector>
using namespace std;


string maxSubstringWrong(string s) {
int n = s.length();

if (n == 0)
return s;

char maxC = 'a' - 1;
std::vector<int> maxInds = std::vector<int>();
int maxCInd = -1;
for (int i = 0; i < n; i++) {
if (s.at(i) == maxC) {
maxInds.push_back(i);
}
else if (s.at(i) > maxC) {
maxInds.clear();
maxC = s.at(i);
maxInds.push_back(i);
}
}

// need a smart way to determine which is the correct substring in maxInds
int maxInd = maxInds.size() - 1;
for (int i = maxInds.size() - 1; i > 0; i--) {
if (s.substr(maxInds[maxInd], n - maxInds[maxInd]) <= s.substr(maxInds[i - 1], n - maxInds[i - 1])) {
maxInd = i;
}
}
return s.substr(maxInd, n - maxInd);

}



/*
�*�Complete�the�'maxSubstring'�function�below.
�*
�*�The�function�is�expected�to�return�a�STRING.
�*�The�function�accepts�STRING�s�as�parameter.
�*/
string maxSubstring(string s) {
int n = s.length();
string maxStr = "";
for (int i = 0; i < n; i++) {
if (maxStr < s.substr(i, n - i))
maxStr = s.substr(i, n - i);
}
return maxStr;
}

int main()
{
std::cout << maxSubstring("aaa") << std::endl;
return 0;
}



// Run program: Ctrl + F5 or Debug > Start Without Debugging menu
// Debug program: F5 or Debug > Start Debugging menu

// Tips for Getting Started:
// 1. Use the Solution Explorer window to add/manage files
// 2. Use the Team Explorer window to connect to source control
// 3. Use the Output window to see build output and other messages
// 4. Use the Error List window to view errors
// 5. Go to Project > Add New Item to create new code files, or Project > Add Existing Item to add existing code files to the project
// 6. In the future, to open this project again, go to File > Open > Project and select the .sln file
Loading