Skip to content

Instantly share code, notes, and snippets.

View rajatgoyal715's full-sized avatar
:octocat:

Rajat Goyal rajatgoyal715

:octocat:
View GitHub Profile
@rajatgoyal715
rajatgoyal715 / ubuntu-boot-repair.md
Last active May 19, 2021 14:49
Ubuntu Boot Repair Commands
@rajatgoyal715
rajatgoyal715 / PaintersPartitionProblem.java
Last active October 1, 2020 14:52
Solution to Painters Partition Problem in Java
import java.util.*;
class PaintersPartitionProblem {
public int paint(int A, int B, int[] C) {
long low = getMax(C); // units to paint when there are infinte number of painters
long high = getSum(C); // units to paint when there is only one painter
while(low < high) {
@rajatgoyal715
rajatgoyal715 / Regexps.md
Last active February 18, 2019 03:40
Some Regular Expressions

URL Regex

((?:ftp|https?):\/\/)?([a-z0-9_]+:[a-z0-9_]+@)?(([a-z0-9.-]+)\.(in|com|net|org|co\.in|co))(:[0-9]+)?(\/.*)?

Email Regex

/([A-Za-z0-9.+-_%/]+)@([A-Za-z0-9-.]+\.[A-Za-z]+)/g

Phone Regex

@rajatgoyal715
rajatgoyal715 / HashMapTest.java
Last active July 25, 2017 13:22
HashMap adding and deleting a key.
import java.util.*;
class HashMapTest{
static HashMap<Integer, Integer> map;
public static void main(String args[]){
map = new HashMap<>();
addKey(1);
deleteKey(1);
}
public static void addKey(int key){
int count = 0;
@rajatgoyal715
rajatgoyal715 / self.c
Last active April 16, 2017 09:09
This program written in C prints out the source code itself.
#include <stdio.h>
int main(void)
{
FILE *fp;
char c;
fp = fopen(__FILE__, "r");
do
{
c=fgetc(fp);
putchar(c);
@rajatgoyal715
rajatgoyal715 / Compare.java
Created April 8, 2017 19:32
Compares new image with a standard image pixel by pixel and find its accuracy percentage.
import java.util.*;
import java.io.*;
import java.awt.*;
import java.awt.image.*;
import javax.imageio.*;
class Compare {
public static void main(String args[]) throws IOException {
File file1 = new File("new-10.bmp");
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in).useDelimiter(", ");
@rajatgoyal715
rajatgoyal715 / LeaveThisOne.java
Created November 17, 2016 13:05
Print the sum of all the numbers in the array except the one at this index.
import java.io.*;
import java.util.*;
public class LeaveThisOne {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int l = in.nextInt();
long arr[] = new long[l];
for(int i=0;i<l;i++)
public class Solution {
public static void main(String []argv)
{
System.out.println("Hello World.");
System.out.println("Hello Java.");
}
}