Skip to content

Commit

Permalink
changes for build
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishektripathi66 committed Nov 15, 2024
1 parent 5ec6ca7 commit 603cb4c
Show file tree
Hide file tree
Showing 63 changed files with 100 additions and 125 deletions.
3 changes: 3 additions & 0 deletions src/Coding Questions/Leetcode/AddtwoNumbers.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
Memory Usage: 48.3 MB, less than 21.62% of Java online submissions for Add Two Numbers.
*
*/

import DS.ListNode;

public class AddtwoNumbers {

public static void main(String[] args) {
Expand Down
14 changes: 14 additions & 0 deletions src/Coding Questions/Leetcode/DS/ListNode.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package DS;

/**
* Definition for singly-linked list.
*
*/
public class ListNode {
public int val;
public ListNode next;
public ListNode() {}
public ListNode(int val) { this.val = val; }
public ListNode(int val, ListNode next) { this.val = val; this.next = next; }
}

Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import DS.ListNode;

/**
2095. Delete the Middle Node of a Linked List
Solved
Expand Down
2 changes: 2 additions & 0 deletions src/Coding Questions/Leetcode/KthLargestSuminaBinaryTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ Return the kth largest level sum in the tree (not necessarily distinct). If ther
import java.util.Arrays;
import java.util.Collections;

import DS.TreeNode;

/**
* Definition for a binary tree node.
* public class TreeNode {
Expand Down
4 changes: 3 additions & 1 deletion src/Coding Questions/Leetcode/LeafSimilarTrees.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import java.util.ArrayList;
import java.util.List;

import DS.TreeNode;

/**
* Definition for a binary tree node.
* public class TreeNode {
Expand All @@ -26,7 +28,7 @@
* }
* }
*/
class Solution {
public class LeafSimilarTrees {

public boolean leafSimilar(TreeNode root1, TreeNode root2) {

Expand Down
12 changes: 0 additions & 12 deletions src/Coding Questions/Leetcode/ListNode.java

This file was deleted.

2 changes: 1 addition & 1 deletion src/Coding Questions/Leetcode/LongestHappyString.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
**/

class Solution {
public class LongestHappyString {
public String longestDiverseString(int a, int b, int c) {
StringBuilder sb = new StringBuilder();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ The map mp may store up to O(n) entries (for each unique number in nums), giving
Square Check and Update: For each number, we check if it’s a perfect square and if its square root has a streak in the map, extending that streak if both conditions are met. Otherwise, we initialize a new streak.
Result Calculation: The maximum streak length is updated continuously, so at the end, res contains the length of the longest square streak.
**/
class Solution {
public class LongestSquareStreakinanArray {
public int longestSquareStreak(int[] nums) {
Map<Integer, Integer> mp = new HashMap<>();
Arrays.sort(nums);
Expand Down
2 changes: 1 addition & 1 deletion src/Coding Questions/Leetcode/LongestValidParentheses.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
.
*/
class Solution {
public class LongestValidParentheses {
public int longestValidParentheses(String s) {
Stack<Integer> stack = new Stack<>();
stack.push(-1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ Choose any node in the binary tree and a direction (right or left).
**/

import DS.TreeNode;

/**
* Definition for a binary tree node.
* public class TreeNode {
Expand All @@ -34,7 +36,7 @@ Choose any node in the binary tree and a direction (right or left).
* }
* }
*/
class Solution {
public class LongestZigZagPathinaBinaryTree {
int count=0;
public int longestZigZag(TreeNode root) {

Expand Down
2 changes: 1 addition & 1 deletion src/Coding Questions/Leetcode/MajorityElementFast.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
The majority element is the element that appears more than ⌊n / 2⌋ times. You may assume that the majority element always exists in the array.
**/
class Solution {
public class MajorityElementFast {
public int majorityElement(int[] nums) {

Map<Integer,Integer> a = new HashMap<>();
Expand Down
2 changes: 1 addition & 1 deletion src/Coding Questions/Leetcode/MakeSumDivisible.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Given an array of positive integers nums, remove the smallest subarray (possibly

import java.util.HashMap;

class MakeSumDivisible {
public class MakeSumDivisible {
public int minSubarray(int[] nums, int p) {
long totalSum = 0;
for (int num : nums) {
Expand Down
2 changes: 1 addition & 1 deletion src/Coding Questions/Leetcode/MaxAverageArray.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
**/


class MaxAverageArray {
public class MaxAverageArray {
public double findMaxAverage(int[] nums, int k) {

double sum = Integer.MIN_VALUE;
Expand Down
2 changes: 1 addition & 1 deletion src/Coding Questions/Leetcode/MaxCandies.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
**/

class MaxCandies {
public class MaxCandies {
public List<Boolean> kidsWithCandies(int[] candies, int extraCandies) {
ArrayList<Boolean> ans=new ArrayList<>();
int max=0;
Expand Down
2 changes: 1 addition & 1 deletion src/Coding Questions/Leetcode/MaxConsecutive.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
**/

class MaxConsecutive {
public class MaxConsecutive {
public int longestOnes(int[] nums, int k) {

int left = 0, right = 0, max = 0, kc = k;
Expand Down
2 changes: 1 addition & 1 deletion src/Coding Questions/Leetcode/MaxKPairs.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
**/

class MaxKPairs {
public class MaxKPairs {
public int maxOperations(int[] nums, int k) {
int res=0;
int l=0;
Expand Down
44 changes: 0 additions & 44 deletions src/Coding Questions/Leetcode/MaxWidthRamp.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
Dishes can be prepared in any order and the chef can discard some dishes to get this maximum value.
*/

class Solution {
public class MaxWidthramp {
public int maxWidthRamp(int[] nums) {
int n = nums.length;
Stack<Integer> stack = new Stack<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ replace nums[i] with ceil(nums[i] / 3).
The ceiling function ceil(val) is the least integer greater than or equal to val.
**/
class Solution {
public class MaximalScoreAfterApplyingKOperations {
public long maxKelements(int[] nums, int k) {
PriorityQueue<Integer>pq = new PriorityQueue<>((a, b)->b-a);
for(int x : nums)
Expand Down
5 changes: 4 additions & 1 deletion src/Coding Questions/Leetcode/MaximumDepthofBinaryTree.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
A binary tree's maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.
**/

import DS.TreeNode;

/**
* Definition for a binary tree node.
* public class TreeNode {
Expand All @@ -25,7 +28,7 @@
* }
* }
*/
class Solution {
public class MaximumDepthofBinaryTree {

public int maxDepth(TreeNode root) {
if(root==null){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import java.util.HashMap;
import java.util.Map;

import DS.TreeNode;

/**
* Definition for a binary tree node.
* public class TreeNode {
Expand All @@ -30,7 +32,7 @@
* }
* }
*/
class Solution {
public class MaximumLevelSumofaBinaryTree {
int maxSum;
int levels;
int[] arrSum = new int[10001];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ From a cell (row, col), you can move to any of the cells: (row - 1, col + 1), (r
Return the maximum number of moves that you can perform.
**/
class Solution {
public class MaximumNumberofMovesinaGrid {
public int maxMoves(int[][] grid) {
// Get dimensions of the grid
int m = grid.length; // number of rows
Expand Down
2 changes: 1 addition & 1 deletion src/Coding Questions/Leetcode/MaximumSwap.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
**/
class Solution {
public class MaximumSwap {
public int maximumSwap(int num) {
List<Integer>arr = new ArrayList<>();
int x = num;
Expand Down
10 changes: 2 additions & 8 deletions src/Coding Questions/Leetcode/MaximumTwinSumofaLinkedList.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,7 @@ In a linked list of size n, where n is even, the ith node (0-indexed) of the lin

import java.util.*;

class ListNode {
int val;
ListNode next;
ListNode() {}
ListNode(int val) { this.val = val; }
ListNode(int val, ListNode next) { this.val = val; this.next = next; }
}
import DS.ListNode;

/** My Solution **/
public class MaximumTwinSumofaLinkedList {
Expand All @@ -54,7 +48,7 @@ public int pairSum(ListNode head) {
}

/** best solution **/
class Solution1 {
class MaximumTwinSumofaLinkedList1 {
private static int [] a = new int[100000];
public int pairSum(ListNode head) {

Expand Down
2 changes: 1 addition & 1 deletion src/Coding Questions/Leetcode/MergeAlternatively.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
merged: a p b q c d
**/

class MergeAlternatively {
public class MergeAlternatively {
public String mergeAlternately(String word1, String word2) {
StringBuilder result = new StringBuilder();
int x = word1.length();
Expand Down
2 changes: 1 addition & 1 deletion src/Coding Questions/Leetcode/MergeTwoSortedList.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@

import DS.ListNode;

/**
* You are given the heads of two sorted linked lists list1 and list2.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Feasibility Check (solve function):
O(1)
**/

class Solution {
public class MinimizedMaximumofProductsDistributedtoAnyStore {
private boolean solve(int n, int[] quantities, int item) {
if (item == 0) return false;
int store = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
**/
//without stack

class Solution {
public class MinimumInsertionstoBalanceaParenthesesString {
public int minInsertions(String s) {
int count=0;
int open=0;
Expand All @@ -46,7 +46,7 @@ public int minInsertions(String s) {

//with stack

class Solution1 {
class MinimumInsertionstoBalanceaParenthesesString1 {
public int minInsertions(String s) {
Stack<Character> stack=new Stack<>();
int count=0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
Return the minimum number of changes required to make the string s beautiful.
**/
class Solution {
public class MinimumNumberofChangestoMakeBinaryStringBeautiful {
public int minChanges(String s) {
int count = 0;
for (int i = 0; i < s.length() - 1; i += 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ There exists some index i (0-indexed) with 0 < i < arr.length - 1 such that:
arr[i] > arr[i + 1] > ... > arr[arr.length - 1]
Given an integer array nums​​​, return the minimum number of elements to remove to make nums​​​ a mountain array.
**/
class Solution {
public class MinimumNumberofRemovalstoMakeMountainArray {
public int minimumMountainRemovals(int[] nums) {
int n = nums.length;
int[] LIS = new int[n], LDS = new int[n];
Expand Down
Loading

0 comments on commit 603cb4c

Please sign in to comment.