Dashboard Temp Share Shortlinks Frames API

cody - HTMLify profile

files of /cody/DevyanshMalhotra/DSA_Solutions/

1171. Remove Zero Sum Consecutive Nodes from Linked List.java /cody/DevyanshMalhotra/DSA_Solutions/1171. Remove Zero Sum Consecutive Nodes from Linked List.java
30 Views
0 Comments
// 1171. Remove Zero Sum Consecutive Nodes from Linked List java solution

/**
* Definition for singly-linked list.
* public c
1255. Maximum Score Words Formed by Letters.java /cody/DevyanshMalhotra/DSA_Solutions/1255. Maximum Score Words Formed by Letters.java
11 Views
0 Comments
// 1255. Maximum Score Words Formed by Letters java solution
class Solution {
public int maxScoreWords(String[] words, char[
128. Longest Consecutive Sequence.java /cody/DevyanshMalhotra/DSA_Solutions/128. Longest Consecutive Sequence.java
11 Views
0 Comments
// 128. Longest Consecutive Sequence
// t.c.:O(n)
class Solution {
public int longestConsecutive(int[] nums) {
int n
138. Copy List with Random Pointer.java /cody/DevyanshMalhotra/DSA_Solutions/138. Copy List with Random Pointer.java
9 Views
0 Comments
/*
// Definition for a Node.
class Node {
int val;
Node next;
Node random;

public Node(int val) {
153. Find Minimum in Rotated Sorted Array.java /cody/DevyanshMalhotra/DSA_Solutions/153. Find Minimum in Rotated Sorted Array.java
16 Views
0 Comments
// 153. Find Minimum in Rotated Sorted Array java solution
class Solution {
public int findMin(int[] nums) {
int lo=
154. Find Minimum in Rotated Sorted Array II.java /cody/DevyanshMalhotra/DSA_Solutions/154. Find Minimum in Rotated Sorted Array II.java
11 Views
0 Comments
// 154. Find Minimum in Rotated Sorted Array II java solution
class Solution {
public int findMin(int[] nums) {
int
155. Min Stack.java /cody/DevyanshMalhotra/DSA_Solutions/155. Min Stack.java
13 Views
0 Comments
// 155. Min Stack java solution

import java.util.Stack;

class MinStack {
Stack<Long> st1 = new Stack<>();
long min;

227. Basic Calculator II.java /cody/DevyanshMalhotra/DSA_Solutions/227. Basic Calculator II.java
19 Views
0 Comments
// 227. Basic Calculator II

class Solution {
public int calculate(String s) {
Stack<Integer> operand = new Stack<>(
234. Palindrome Linked List.java /cody/DevyanshMalhotra/DSA_Solutions/234. Palindrome Linked List.java
16 Views
0 Comments
// 234. Palindrome Linked List

/**
* Definition for singly-linked list.
* public class ListNode {
* int val;
* List
239. Sliding Window Maximum.java /cody/DevyanshMalhotra/DSA_Solutions/239. Sliding Window Maximum.java
9 Views
0 Comments
// 239. Sliding Window Maximum java solution
class Solution {
public int[] maxSlidingWindow(int[] nums, int k) {
Deq
240. Search a 2D Matrix II.java /cody/DevyanshMalhotra/DSA_Solutions/240. Search a 2D Matrix II.java
31 Views
0 Comments
// 240. Search a 2D Matrix II java solution
class Solution {
public boolean searchMatrix(int[][] matrix, int target) {

287. Find the Duplicate Number.java /cody/DevyanshMalhotra/DSA_Solutions/287. Find the Duplicate Number.java
16 Views
0 Comments
// 287. Find the Duplicate Number java solution

class Solution {
public int findDuplicate(int[] nums) {
int n= nums
33. Search in Rotated Sorted Array.java /cody/DevyanshMalhotra/DSA_Solutions/33. Search in Rotated Sorted Array.java
10 Views
0 Comments
// 33. Search in Rotated Sorted Array java solution
class Solution {
public int search(int[] nums, int target) {
int
349. Intersection of Two Arrays.java /cody/DevyanshMalhotra/DSA_Solutions/349. Intersection of Two Arrays.java
35 Views
0 Comments
// 349. Intersection of Two Arrays

class Solution {
public int[] intersection(int[] nums1, int[] nums2) {
Set<Integ
380. Insert Delete GetRandom O(1).java /cody/DevyanshMalhotra/DSA_Solutions/380. Insert Delete GetRandom O(1).java
12 Views
0 Comments
// 380. Insert Delete GetRandom O(1)
class RandomizedSet {
HashMap<Integer, Integer> hm;
List<Integer> list;
Random
381. Insert Delete GetRandom O(1) - Duplicates allowed.java /cody/DevyanshMalhotra/DSA_Solutions/381. Insert Delete GetRandom O(1) - Duplicates allowed.java
11 Views
0 Comments
// 381. Insert Delete GetRandom O(1) - Duplicates allowed
class RandomizedCollection {
HashMap<Integer,HashSet<Integer>> map
4. Median of Two Sorted Arrays.java /cody/DevyanshMalhotra/DSA_Solutions/4. Median of Two Sorted Arrays.java
11 Views
0 Comments
// 4. Median of Two Sorted Arrays java solution

class Solution {
public double findMedianSortedArrays(int[] nums1, int[] nu
438. Find All Anagrams in a String.java /cody/DevyanshMalhotra/DSA_Solutions/438. Find All Anagrams in a String.java
27 Views
0 Comments
// 438. Find All Anagrams in a String

class Solution {
public List<Integer> findAnagrams(String s, String p) {
int
442. Find All Duplicates in an Array.java /cody/DevyanshMalhotra/DSA_Solutions/442. Find All Duplicates in an Array.java
12 Views
0 Comments
// 442. Find All Duplicates in an Array java solution

class Solution {
public List<Integer> findDuplicates(int[] nums) {

525. Contiguous Array.java /cody/DevyanshMalhotra/DSA_Solutions/525. Contiguous Array.java
27 Views
0 Comments
// 525. Contiguous Array java solution

import java.util.HashMap;

class Solution {
public int findMaxLength(int[] arr) {

543. Diameter of Binary Tree.java /cody/DevyanshMalhotra/DSA_Solutions/543. Diameter of Binary Tree.java
33 Views
0 Comments
// 543. Diameter of Binary Tree java solution

/**
* Definition for a binary tree node.
* public class TreeNode {
* int v
560. Subarray Sum Equals K.java /cody/DevyanshMalhotra/DSA_Solutions/560. Subarray Sum Equals K.java
11 Views
0 Comments
// 560. Subarray Sum Equals K o(n) t.c. solution
class Solution {
public int[] psum(int[] nums){
int[] ps=new int[nu
710. Random Pick with Blacklist.java /cody/DevyanshMalhotra/DSA_Solutions/710. Random Pick with Blacklist.java
13 Views
0 Comments
// 710. Random Pick with Blacklist
class Solution {
HashMap<Integer,Integer> map;
Random r;
int valid;
public So
76. Minimum Window Substring.java /cody/DevyanshMalhotra/DSA_Solutions/76. Minimum Window Substring.java
9 Views
0 Comments
// 76. Minimum Window Substring
class Solution {
public String minWindow(String s, String t) {
int slen=s.length();

81. Search in Rotated Sorted Array II.java /cody/DevyanshMalhotra/DSA_Solutions/81. Search in Rotated Sorted Array II.java
9 Views
0 Comments
// 81. Search in Rotated Sorted Array II java solution
class Solution {
public boolean search(int[] nums, int target) {

84. Largest Rectangle in Histogram.java /cody/DevyanshMalhotra/DSA_Solutions/84. Largest Rectangle in Histogram.java
26 Views
0 Comments
// 84. Largest Rectangle in Histogram leetcode hard problem java code

class Solution {
public int largestRectangleArea(int[
85. Maximal Rectangle.java /cody/DevyanshMalhotra/DSA_Solutions/85. Maximal Rectangle.java
22 Views
0 Comments
// 85. Maximal Rectangle leetcode hard java solution

class Solution {
public int maximalRectangle(char[][] matrix) {

895. Maximum Frequency Stack.java /cody/DevyanshMalhotra/DSA_Solutions/895. Maximum Frequency Stack.java
23 Views
0 Comments
// 895. Maximum Frequency Stack

class FreqStack {
HashMap<Integer, Stack<Integer>> st;
HashMap<Integer, Integer> fmap;

930. Binary Subarrays With Sum.java /cody/DevyanshMalhotra/DSA_Solutions/930. Binary Subarrays With Sum.java
12 Views
0 Comments
// 930. Binary Subarrays With Sum

import java.util.HashMap;

class Solution {
public int numSubarraysWithSum(int[] nums, in
Anagram Palindrome.java /cody/DevyanshMalhotra/DSA_Solutions/Anagram Palindrome.java
12 Views
0 Comments
// Anagram Palindrome
//{ Driver Code Starts
import java.util.*;
import java.lang.*;
import java.io.*;

class GFG
{
Count Pairs whose sum is equal to X.java /cody/DevyanshMalhotra/DSA_Solutions/Count Pairs whose sum is equal to X.java
24 Views
0 Comments
// Count Pairs whose sum is equal to X

import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import
D. Same Differences.java /cody/DevyanshMalhotra/DSA_Solutions/D. Same Differences.java
12 Views
0 Comments
// D. Same Differences
// "static void main" must be defined in a public class.
import java.util.Scanner;
import java.util.HashM
Equal 0, 1 and 2(2).java /cody/DevyanshMalhotra/DSA_Solutions/Equal 0, 1 and 2(2).java
11 Views
0 Comments
// Equal 0, 1 and 2 solution without using extra function
class Solution
{
long getSubstringWithEqual012(String str)

Equal 0, 1 and 2.java /cody/DevyanshMalhotra/DSA_Solutions/Equal 0, 1 and 2.java
17 Views
0 Comments
// Equal 0, 1 and 2 solution using extra function
class Solution
{
long getSubstringWithEqual012(String str)
{

Generate Binary Numbers.java /cody/DevyanshMalhotra/DSA_Solutions/Generate Binary Numbers.java
11 Views
0 Comments
// Generate Binary Numbers java solution

import java.util.*;
import java.io.*;
import java.lang.*;

class GFG
{
HashMap Operations.java /cody/DevyanshMalhotra/DSA_Solutions/HashMap Operations.java
12 Views
0 Comments
// HashMap Operations
//{ Driver Code Starts
import java.util.Scanner;
import java.util.*;

class HashMap_Set3
{
public static
Help Classmates.java /cody/DevyanshMalhotra/DSA_Solutions/Help Classmates.java
27 Views
0 Comments
// Help Classmates gfg problem



import java.util.*;
import java.io.*;

class GFG
Intersection Point in Y Shaped Linked Lists.java /cody/DevyanshMalhotra/DSA_Solutions/Intersection Point in Y Shaped Linked Lists.java
25 Views
0 Comments
// Intersection Point in Y Shaped Linked Lists java solution

//{ Driver Code Starts
import java.util.*;


class Node
{
LICENSE /cody/DevyanshMalhotra/DSA_Solutions/LICENSE
34 Views
0 Comments
MIT License

Copyright (c) 2024 Devyansh Malhotra

Permission is hereby granted, free of charge, to any person obtaining a copy

LRU cache.java /cody/DevyanshMalhotra/DSA_Solutions/LRU cache.java
17 Views
0 Comments
class Node{
Node next;
Node prev;
int key;
int val;
public Node(){

}
Left View of Binary Tree.java /cody/DevyanshMalhotra/DSA_Solutions/Left View of Binary Tree.java
14 Views
0 Comments
// Left View of Binary Tree java solutions

class Tree
{
//Function to return list containing elements of left view of binar
Longest Sub-Array with Sum K.java /cody/DevyanshMalhotra/DSA_Solutions/Longest Sub-Array with Sum K.java
10 Views
0 Comments
// Longest Sub-Array with Sum K java solution
import java.io.*;
import java.util.*;


class Array {

// Driver code
Longest Unbalanced subsequence.java /cody/DevyanshMalhotra/DSA_Solutions/Longest Unbalanced subsequence.java
25 Views
0 Comments
// Longest Unbalanced subsequence java solution

import java.io.*;
import java.util.*;

public class Solution {
public stati
Maximum Sum Problem.java /cody/DevyanshMalhotra/DSA_Solutions/Maximum Sum Problem.java
21 Views
0 Comments
// Maximum Sum Problem

import java.io.*;
import java.util.*;
class GfG
{
public static void main(String args[])
{
Merge Sort for Linked List.java /cody/DevyanshMalhotra/DSA_Solutions/Merge Sort for Linked List.java
16 Views
0 Comments
// Merge Sort for Linked List java solution

//{ Driver Code Starts
//Initial Template for Java

import java.util.*;
import java
Merge two sorted linked lists.java /cody/DevyanshMalhotra/DSA_Solutions/Merge two sorted linked lists.java
24 Views
0 Comments
// Merge two sorted linked lists java solution
//{ Driver Code Starts
import java.util.*;

class Node
{
int data;
Node n
Next Greater Element.java /cody/DevyanshMalhotra/DSA_Solutions/Next Greater Element.java
26 Views
0 Comments
// Next Greater Element

import java.util.*;
import java.lang.*;
import java.io.*;

class GFG {

README.md /cody/DevyanshMalhotra/DSA_Solutions/README.md
28 Views
0 Comments
# DSA Solutions

Welcome to the DSA Solutions Repository! This repository is a read-only collection of solutions to some of the
Smallest number on left.java /cody/DevyanshMalhotra/DSA_Solutions/Smallest number on left.java
11 Views
0 Comments
import java.io.*;
import java.util.*;
import java.lang.*;

class GFG{
public static void main(String args[])throws IOExcepti
Stock span problem.java /cody/DevyanshMalhotra/DSA_Solutions/Stock span problem.java
25 Views
0 Comments
// Stock span problem

import java.util.*;
import java.io.*;
import java.lang.*;

class gfg
{
Subarrays with equal 1s and 0s.java /cody/DevyanshMalhotra/DSA_Solutions/Subarrays with equal 1s and 0s.java
13 Views
0 Comments
// Subarrays with equal 1s and 0s solution with t.c:O(n)

class Solution
{
//Function to count subarrays with 1s and 0s.

Subarrays(2) with equal 1s and 0s.java /cody/DevyanshMalhotra/DSA_Solutions/Subarrays(2) with equal 1s and 0s.java
23 Views
0 Comments
class Solution
{
//Function to count subarrays with 1s and 0s without extra functions usage
static int countSubarrWithEq
Sum of bit differences.java /cody/DevyanshMalhotra/DSA_Solutions/Sum of bit differences.java
23 Views
0 Comments
// Sum of bit differences java solution brute force followed by optimal


import java.io.BufferedReader;
import java.io.InputStr
TreeMap Operations.java /cody/DevyanshMalhotra/DSA_Solutions/TreeMap Operations.java
11 Views
0 Comments
// TreeMap Operations java solution
//{ Driver Code Starts
import java.util.Scanner;
import java.util.*;
class HashMap_Set4
{
p
Vertical Traversal of Binary Tree.java /cody/DevyanshMalhotra/DSA_Solutions/Vertical Traversal of Binary Tree.java
10 Views
0 Comments
// Vertical Traversal of Binary Tree java solution

//{ Driver Code Starts
//Initial Template for Java

//Contributed by Sudarsh
Zero Sum Subarrays.java /cody/DevyanshMalhotra/DSA_Solutions/Zero Sum Subarrays.java
24 Views
0 Comments
// Zero Sum Subarrays O(n) solution
class Solution{
//Function to count subarrays with sum equal to 0.
public static lon
kadane.c /cody/DevyanshMalhotra/DSA_Solutions/kadane.c
21 Views
0 Comments
#include<stdio.h>
int maxSubArray(int* nums, int numsSize){
int i,sum=0;
int maxNum=nums[0];
for(i=0;i< numsSize
lca_in_binarytree.java /cody/DevyanshMalhotra/DSA_Solutions/lca_in_binarytree.java
21 Views
0 Comments
// lca in binary tree gfg

class Solution
{
//Function to return the lowest common ancestor in a Binary Tree.
Node lca(Node
major_element2.c /cody/DevyanshMalhotra/DSA_Solutions/major_element2.c
30 Views
0 Comments
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

int* majorityElement(int* nums, int numsSize, int* returnSize);
max_product.c /cody/DevyanshMalhotra/DSA_Solutions/max_product.c
15 Views
0 Comments
#include<stdio.h>
int maxProduct(int* nums, int numsSize) {
int i, maxProduct = 1, minProduct = 1, maxResult = nums[i];

maxchunks.c /cody/DevyanshMalhotra/DSA_Solutions/maxchunks.c
35 Views
0 Comments
int maxChunksToSorted(int* arr, int arrSize) {
int i,max_chunks = 0;
int current_max = 0;

for (i = 0; i < a
maxnum_occur.c /cody/DevyanshMalhotra/DSA_Solutions/maxnum_occur.c
36 Views
0 Comments
#include<stdio.h>
int majorityElement(int* nums, int numsSize) {
int candidate = nums[0];
int i, count = 1;


next_greater_ele3.c /cody/DevyanshMalhotra/DSA_Solutions/next_greater_ele3.c
18 Views
0 Comments
#include <stdio.h>
#include <string.h>

void swap(char *a, char *b) {
char temp = *a;
*a = *b;
*b = temp;
}
rotate_array.c /cody/DevyanshMalhotra/DSA_Solutions/rotate_array.c
20 Views
0 Comments
#include <stdio.h>

void rotate(int* nums, int numsSize, int k) {
int i;
k = k % numsSize;
int* temp = malloc(nums
sliding window minimum.java /cody/DevyanshMalhotra/DSA_Solutions/sliding window minimum.java
10 Views
0 Comments
// sliding window minimum java solution

import java.util.*;

class SlidingWindowMinimum {

public ArrayList<Integer> getMinim
square_and_sort_array.c /cody/DevyanshMalhotra/DSA_Solutions/square_and_sort_array.c
25 Views
0 Comments
#include <stdio.h>
#include <stdlib.h>

int* sortedSquares(int* nums, int numsSize, int* returnSize) {
int i, j,temp;