Skip to content

Instantly share code, notes, and snippets.

View EnesKorukcu's full-sized avatar
🎯

Enes Korukcu EnesKorukcu

🎯
  • Amsterdam
View GitHub Profile
@EnesKorukcu
EnesKorukcu / gist:c326cc405c7fb2df8913
Last active August 29, 2015 14:16
Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures ?
/**
* Solution 1
* Time Complexity : O(n) where n is the length of the string
* Space Complexity : O(1)
* @param input
* @return boolean
*/
public static boolean checkSingularity1(String input) {
if(input.length() > 256) {
return false;
@EnesKorukcu
EnesKorukcu / gist:aadf52592d3a520078be
Last active August 29, 2015 14:16
Given two strings, write a method to decide if one is a permutation of the other.
/**
* Solution 1
* @param str1
* @param str2
* @return boolean
*/
public static boolean findIfStringsArePermutationOfEachOther(String str1, String str2) {
if(str1.length() != str2.length()) {
return false;
}
@EnesKorukcu
EnesKorukcu / gist:ffe60030d98122b8d1e3
Last active August 29, 2015 14:16
Write a method to replace all spaces in a string with '%20'. You may assume that the string has sufficient space at the end of the string to hold the additional characters, and that you are given the "true" length of the string. (Note: if implementing in Java, please use a character array so that you can perform this operation in place.)
public static String replaceSpaces(String input) {
char[] inputChars = input.toCharArray();
StringBuilder stringBuilder = new StringBuilder(input);
for(int i = 0; i < inputChars.length; i++) {
if(inputChars[i] == ' ') {
stringBuilder.append("%20");
} else {
stringBuilder.append(inputChars[i]);
}
stringBuilder.deleteCharAt(stringBuilder.length() - i);
@EnesKorukcu
EnesKorukcu / gist:b740e63032f3facd7873
Last active August 29, 2015 14:16
Implement a method to perform basic string compression using the counts of repeated characters. For example, the string aabcccccaaa would become a2blc5a3. If the "compressed" string would not become smaller than the original string, your method should return the original string.
/**
* Solution 1
* Bad Solution
* Time Complexity: 0(p + k2), where p is the size of the original string and k is the number of character sequences
*/
public static String compressBad(String input) {
String output = "";
int charCount = 0;
char[] charArray = input.toCharArray();
char temp = input.charAt(0);
@EnesKorukcu
EnesKorukcu / foo.md
Created July 18, 2019 13:30 — forked from rmoff/foo.md
cx_Oracle install on MacOS
  1. Download Instant Client:
  • instantclient-basic-macos.x64-11.2.0.4.0.zip
  • instantclient-sdk-macos.x64-11.2.0.4.0.zip
  • instantclient-sqlplus-macos.x64-11.2.0.4.0.zip
  1. Unzip and move to /opt

  2. Create symlink

@EnesKorukcu
EnesKorukcu / swagger_json_to_postman_json.sh
Last active November 5, 2019 14:59
Import swagger json into postman
//
// This script creates a postman.json file from swagger.json which can be imported into postman.
// 1. Replace "YOUR_PROJECT_URL" with real url which points to swagger.json.
// 2. Give permission to run: "chmod +x swagger_json_to_postman_json.sh"
// 3. Execute the script: "./swagger_json_to_postman_json.sh"
// 4. postman.json will be created in the same folder as script.
//
git clone https://github.com/postmanlabs/openapi-to-postman.git
cd openapi-to-postman