Skip to content

Instantly share code, notes, and snippets.

View m3hdiii's full-sized avatar
🏁
Focusing

Mehdi Afsari m3hdiii

🏁
Focusing
View GitHub Profile
@m3hdiii
m3hdiii / gist:dfd90928f597e25bf0be4b60dffdeffd
Created January 3, 2021 08:33
Write Java code for this problem and analyze its complexity: Given an array of distinct integers and a target sum, find two numbers in the array that add up to the target sum.
import java.util.LinkedHashSet;
import java.util.Set;
public class Test {
public static void main(String[] args) {
int[] arr = {4, 5, 7, -5 - 3, 2, 8, 5, -1, 3, 8};
int[] distinctIntArray = makeDistinct(arr);
getPairsCount(distinctIntArray, 9);
}
<dependencies>
<dependency>
<groupId>javax.el</groupId>
<artifactId>javax.el-api</artifactId>
<version>2.2.4</version>
</dependency>
<dependency>
<groupId>org.glassfish.web</groupId>
@m3hdiii
m3hdiii / gist:de45340f821d9528d928f3c0941a3fa1
Created March 4, 2018 02:14
Code For Regex Matching For all letters excepts symbols
public class Test {
public static void main(String[] args) {
String textWithsymbols = "Th!s is For $ & NoT 4 Honey ... !@#$?<>%^&Y~*()_-=+aah جاوا فور اور";
String s = textWithsymbols.replaceAll("[\\\\s\\\\d!\\\"#$%&\\'()*+,-./:;\\\\\\\\<>=?@\\\\^_`{}|~\\\\[\\\\]]","");
System.out.println(s);
}
}