This file contains hidden or 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
class Solution { | |
public: | |
string toLowerCase(string str) { | |
for(int i = 0; i < str.size(); i++){ | |
int ascii = (int)(str[i]); | |
if(ascii <= 90 and ascii > 64 ){ //means it's uppercase letter | |
str[i] = char(((int)(str[i])) + 32); | |
} | |
} | |
return str; |
This file contains hidden or 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
class Solution { | |
public: | |
bool isPalindrome(string sub){ | |
string other = ""; | |
for(int i = (sub.size() - 1); i >= 0; i--){ | |
other += sub[i]; | |
} | |
return other == sub; | |
} | |
string longestPalindrome(string s) { |
This file contains hidden or 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
class Solution { | |
public: | |
void reverseString(vector<char>& s) { | |
int length = s.size(); | |
int j = length - 1; | |
int first_val; | |
for(int i = 0; i < length;i++){ | |
if (i <= j){ | |
This file contains hidden or 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
class Solution { | |
public: | |
vector<int> twoSum(vector<int>& nums, int target) { | |
std::unordered_map<int,int> dict; | |
for(int i = 0; i < nums.size();i++){ | |
int complement = target - nums[i]; | |
if (dict.find(complement) != dict.end()){ | |
//complement is in the unordered map |
This file contains hidden or 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
// | |
// main.cpp | |
// Fibonacci | |
// | |
// Created by Bharddwaj on 5/31/19. | |
// Copyright © 2019 Bharddwaj. All rights reserved. | |
// | |
#include <iostream> | |
#include <map> | |
#include <chrono> |
This file contains hidden or 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 <iostream> | |
#define _USE_MATH_DEFINES | |
#include <math.h> | |
int main(int argc, const char * argv[]) { | |
// insert code here... | |
std::cout << "Hello, World!\n"; | |
// const int sideLength = 2; Square Area 4 | |
// const int radius = 1; Circle Area PI |
This file contains hidden or 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
import java.util.Random; | |
public class DNA { | |
// The genetic sequence | |
char[] genes; | |
char[] alpha = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z',' '}; | |
float fitness; | |
// Constructor (makes a random DNA) | |
public DNA(int num) { | |
Random r = new Random(); |
This file contains hidden or 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
// Generate a mating pool | |
public void naturalSelection() { | |
// Clear the ArrayList | |
matingPool.clear(); | |
Float [] fitnessArray = new Float[Population.size()]; | |
float maxFitness = 0; | |
float fitness = 0; | |
float sum = 0; | |
for (int i = 0; i < Population.size(); i++) { | |
fitness = Population.get(i).fitness; |
This file contains hidden or 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
#!/usr/bin/env python3 | |
# Python 3.6 | |
# Import the Halite SDK, which will let you interact with the game. | |
import hlt | |
# This library contains constant values. | |
from hlt import constants | |
# This library contains direction metadata to better interface with the game. |
This file contains hidden or 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
package com.company; //idek how to java lol | |
import com.bloomberglp.blpapi.CorrelationID; | |
import com.bloomberglp.blpapi.Event; | |
import com.bloomberglp.blpapi.Message; | |
import com.bloomberglp.blpapi.MessageIterator; | |
import com.bloomberglp.blpapi.Request; | |
import com.bloomberglp.blpapi.Service; | |
import com.bloomberglp.blpapi.Session; |