Skip to content

Instantly share code, notes, and snippets.

View raghavddps2's full-sized avatar
🎯
Focusing

Raghav Maheshwari raghavddps2

🎯
Focusing
View GitHub Profile
import math
n = int(input())
edges = int(input())
space = [-1 for i in range(0,n+1)]
count = 0
for i in range(0,edges):
a,b = map(int,input().split())
if a > b:
temp = a
import java.util.*;
public class detectGraphCycles {
public static void main(String[] args) {
int n = 4;
int src = 0;
int graph[][] = {
{0,1,0,0},
{0,0,1,0},
{0,1,0,0},
{1,0,1,0}
final String phpEndPoint = 'http://192.168.43.171/phpAPI/image.php';
final String nodeEndPoint = 'http://192.168.43.171:3000/image';File file;
void _choose() async {
file = await ImagePicker.pickImage(source: ImageSource.camera);
// file = await ImagePicker.pickImage(source: ImageSource.gallery);
}
void _upload() {
if (file == null) return;
def commonWhites(N,M,arr1,arr2,arr3):
flatten1 = set(sum(arr1,[]))
flatten2 = set(sum(arr2,[]))
flatten3 = set(sum(arr3,[]))
ans = flatten1.intersection(flatten2).intersection(flatten3)
if(len(ans) == 0):
return -1
else:
return len(ans)
def strangeStrings(string,n):
string1 = string[0:n]
string2 = string[n:]
arr1 = [False for i in range(0,n)]
arr2 = [False for i in range(n,len(string))]
strAns = ""
while ((string1 != "") and (string2 != "")):
min1 = min(string1)
min2 = min(string2)
@raghavddps2
raghavddps2 / BreadthFirstSearch.java
Created September 28, 2020 18:30
Simple Breadth First Search - Adjacency List & Adjacency Matrix Implementation
import java.util.*;
public class BreadthFirstSearch{
/**
* What exactly is breadth first search, we find a start node and we go through all the connected nodes
* and all then we put in a queue and go ahead, on the way we keep marking the nodes as visited.
*
* 1. The complexity if we use an Adjacency Matrix is O(Vertices^2)
* 2. The complexity if we use an Adjacency List is O(V+E)
*
* Reason: In case of an Adjacency Matrix, we will be going through all the possible cells in a matrix
@raghavddps2
raghavddps2 / ques2.py
Last active September 28, 2020 08:30
mouse_selected = -1
keyboard_selected = -1
def printClosest(m,n,a1,a2,money):
max_amt = 0
for i in range(0,len(a1)):
sum = 0
for j in range(0,len(a2)):
sum = a1[i] + a2[j]
@raghavddps2
raghavddps2 / ques.py
Last active September 28, 2020 08:18
def reverse(number):
reverse = 0
while(number > 0):
mod_num = number % 10
reverse = reverse * 10 + mod_num
number = number // 10
return reverse
def shuffle(m1,m2):
rev_num1 = reverse(m1)
public static List<Integer> sortIntersect(List<Integer> volcanic,List<Integer> nonVolcanic){
List<Integer> ans = new ArrayList<Integer>();
int i = 0, j = 0;
Collections.sort(volcanic);
Collections.sort(nonVolcanic);
while (i < volcanic.size() && j < nonVolcanic.size())
{
if (volcanic.get(i) > nonVolcanic.get(j))
{
import java.util.*;
public class Skiils{
public static void main(String[] args) {
HashMap<Character,Integer> hMap = new HashMap<Character,Integer>();
Scanner sc = new Scanner(System.in);
String str = sc.nextLine();
for(int i=0;i<str.length();i++){
if(hMap.containsKey(str.charAt(i))){
hMap.put(str.charAt(i),hMap.get(str.charAt(i))+1);
}