Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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
// C/C++ program to solve greedy mobile Manuf. | |
#include <bits/stdc++.h> | |
using namespace std; | |
// Structure for an Mobile which stores Parts manf. and Assembling | |
struct Mobile | |
{ | |
int pm, assm; |
This file contains 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
public static int getTotalX(List<Integer> a, List<Integer> b) { | |
Collections.sort(a); Collections.sort(b); | |
int lcmOfa = lcmOfNumbers(a); | |
int gcdofb = b.get(0); | |
for(int i=1; i<b.size(); i++){ | |
gcdofb = gcd(gcdofb,b.get(i)); | |
} | |
int start = lcmOfa; | |
int end = gcdofb; | |
int count=0; |
This file contains 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 int numIslands(char[][] grid) { | |
int vis[][] = new int[301][301]; | |
for(int[] m:vis) Arrays.fill(m,0); | |
int[][] river = new int[grid.length][grid[0].length]; | |
for(int i=0; i<grid.length; i++){ | |
for(int j=0; j<grid[i].length; j++){ | |
int val = grid[i][j]-'0'; | |
river[i][j]=val; | |
} |
This file contains 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.*; | |
public class Solution { | |
public static int tripletSum(int[] A, int num) { | |
Arrays.sort(A);// nlog(n) | |
int len = A.length; | |
int count = 0; | |
for(int i=0; i<len; i++) { | |
int pairsum=num -A[i]; | |
count+=getPairsCount(A,i+1, len-1,pairsum); |