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.List; | |
import java.util.Scanner; | |
import java.util.Stack; | |
public class ExclusiveTimeOfFunction { | |
public static Scanner input = new Scanner(System.in); | |
public static void main(String[] args) { | |
int n; | |
int logsNum; |
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.List; | |
import java.util.Map; | |
class LetterCombinations | |
{ | |
private List<String> combinations = new ArrayList<>(); | |
private Map<Character, String> letters = Map.of( | |
'2', "abc", '3', "def", '4', "ghi", '5', "jkl", | |
'6', "mno", '7', "pqrs", '8', "tuv", '9', "wxyz"); |
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.LinkedList; | |
import java.util.Queue; | |
public class SerializeDeserializeBinaryTree { | |
//Definition for a binary tree node. | |
public class TreeNode { | |
int val; | |
TreeNode left; | |
TreeNode right; | |
TreeNode(int x) { val = x; } |
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 Main { | |
public static Scanner input = new Scanner(System.in); | |
public static void main(String[] args) { | |
String s = input.next(); | |
String t = input.next(); | |
Solution solution = new Solution() | |
System.out.println(solution.minWindow(s, t)); | |
} |
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 | |
{ | |
//The function checks if a substring with given start and end points | |
//is a palindrome or not. | |
public boolean isPalindrome(String s, int start, int end) | |
{ | |
while (start < end) | |
{ | |
if (s.charAt(start) != s.charAt(end)) | |
return false; |
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 | |
{ | |
private String findLongestPalindromicSubstring(String input) | |
{ | |
//If empty, does not analyze the string | |
if(input.isEmpty()) | |
{ | |
return ""; | |
} |
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 LRUCache { | |
//double linked list class | |
class DLinkedNode { | |
int key; | |
int value; | |
DLinkedNode prev; | |
DLinkedNode next; |
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.*; | |
class Solution { | |
public int[] findOrder(int numCourses, int[][] prerequisites) { | |
//A map to model the graph | |
Map<Integer, List<Integer>> adjList = new HashMap<Integer, | |
List<Integer>>(); | |
//To save the indegree of each node in the graph |
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 { | |
//Takes a 2D array as the input | |
public int numIslands(char[][] grid) { | |
//If empty, returns 0 | |
if(grid == null || grid.length == 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
import java.util.Arrays; | |
import java.util.Comparator; | |
public class Solution { | |
//A method to return the number of used rooms | |
public int minMeetingRooms(int[][] intervals) { | |
//If input == null, does not process it |
OlderNewer