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.ArrayList; | |
import java.util.Arrays; | |
import java.util.List; | |
public class ThreeSum { | |
public static List<List<Integer>> threeSum(int[] nums) { | |
List<List<Integer>> result = new ArrayList<>(); | |
Arrays.sort(nums); |
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.HashMap; | |
public class LongestCommonSubString { | |
public static void main(String[] args) { | |
long start =System.currentTimeMillis(); | |
String B = "abcdefg"; | |
String A = "xcdey"; | |
HashMap<String, Integer> map = new HashMap<>(); | |
find(A, B, map); |
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.Arrays; | |
import java.util.Comparator; | |
public class MaximumProfitJobs { | |
public int jobScheduling(int[] startTime, int[] endTime, int[] profit) { | |
int numJobs = profit.length; // Number of jobs | |
Job[] jobs = new Job[numJobs]; | |
for (int i = 0; i < numJobs; ++i) { |
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 class Main { | |
public static Map<Integer, Integer> ht = new HashMap<>();; | |
public static void topView(Node root, int level) { | |
if (root == null) | |
return; | |
Queue<QueuePack> queue = new LinkedList<>(); | |
queue.add(new QueuePack(level, root)); |
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.Arrays; | |
public class MaxRepeatingUsingSorting { | |
public void maxRepeatingElementUsingSorting(int [] arrA){ | |
if(arrA.length<1){ | |
System.out.println("Inavlid Array"); | |
return; | |
} | |
Arrays.sort(arrA); | |
int count=1; |
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.Stack; | |
public class ReverseDLL { | |
static class Node{ | |
int data; | |
Node prev; | |
Node next; | |
public Node(int data){ |
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.Stack; | |
public class ReverseLL { | |
static class Node { | |
int data; | |
Node next; | |
public Node(int data) { | |
this.data = data; |
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
package main | |
import "fmt" | |
func findTwoRepeating(A []int) { | |
fmt.Print("Repeated Elements: ") | |
for i := 0; i < len(A); i++ { | |
for j := i + 1; j < len(A); j++ { | |
if A[i] == A[j] { | |
fmt.Print(A[i], " ") |
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
def find_two_repeating(A): | |
print("Repeated Elements:") | |
for i in range(len(A)): | |
for j in range(i + 1, len(A)): | |
if A[i] == A[j]: | |
print(A[i], end=" ") | |
if __name__ == "__main__": | |
A = [1, 5, 2, 4, 8, 9, 3, 1, 4, 0] | |
find_two_repeating(A) |
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 MinimumCostStaircaseRecursion: | |
def minCost(self, cost): | |
stairs = len(cost) - 1 | |
return self.util(cost, -1, stairs) | |
def util(self, cost, current, stairs): | |
if current == stairs: | |
return cost[current] | |
if current > stairs: |
NewerOlder