-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
108bff5
commit fcb2668
Showing
37 changed files
with
860 additions
and
179 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package com.DP;public class FiboSeries { | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package com.DP;public class FrogJump2 { | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package com.DP;public class climbStairs { | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package com.DSA;public class BST { | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package com.DSA;public class BinaryTree { | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package com.Exam;public class tp { | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
package com.Java_Classes;public class Staff { | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.Practice; | ||
|
||
public class ExcelSheet { | ||
public static void main(String[] args) { | ||
System.out.println(findIndex("ZZZ")); | ||
} | ||
static int findIndex(String str){ | ||
return getIndex(str,0); | ||
} | ||
|
||
private static int getIndex(String str, int ans) { | ||
if(str.isEmpty()){ | ||
return ans; | ||
} | ||
int temp = str.charAt(0);//AA A-->65 | ||
if(temp < 65 || temp > 90){ | ||
return 0; | ||
} | ||
temp = temp % 64 ; | ||
ans = 26 * ans + temp; | ||
return getIndex(str.substring(1),ans); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package com.Practice; | ||
|
||
public class GoodPosition { | ||
public static void main(String[] args) { | ||
int [] arr = {1,4,3}; | ||
System.out.println(findPosition(arr , 3 , 3)); | ||
} | ||
static int findPosition(int [] arr , int n,int k ){ | ||
int sum = 0; | ||
for(int i =0; i < n ; i++ ){ | ||
sum = sum + arr[i]; | ||
} | ||
return findPos(arr,0,k,sum , 0); | ||
} | ||
|
||
private static int findPos(int[] arr, int i, int k, int sum,int ans) { | ||
if(i == arr.length){ | ||
return ans; | ||
} | ||
if((arr[i]+k) > (sum-arr[i])){ | ||
ans++; | ||
return findPos(arr , i+1,k,sum,ans); | ||
}else{ | ||
return findPos(arr , i+1,k,sum,ans); | ||
} | ||
} | ||
|
||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.Practice; | ||
|
||
import java.util.Stack; | ||
|
||
//leetcode 84 | ||
public class LargestAreaHistogram { | ||
public static void main(String[] args) { | ||
int []heights ={2,1,5,6,2,3}; | ||
System.out.println(largestRectangleArea(heights)); | ||
} | ||
|
||
public static int largestRectangleArea(int [] heights){ | ||
Stack<Integer>stack = new Stack<>(); | ||
int max = 0; | ||
|
||
stack.push(0); | ||
for(int i = 1; i< heights.length ; i++){ | ||
while(!stack.isEmpty() && heights[i] < heights[stack.peek()]){ | ||
max = getMax(heights,stack,max,i); | ||
} | ||
stack.push(i); | ||
} | ||
int i = heights.length; | ||
while(!stack.isEmpty()){ | ||
max = getMax(heights,stack,max,i); | ||
} | ||
return max; | ||
} | ||
static int getMax(int [] heights , Stack<Integer> stack , int max, int index){ | ||
int area; | ||
int popped =stack.pop(); | ||
if(stack.isEmpty()){ | ||
area = heights[popped] * index; | ||
}else{ | ||
area = heights[popped] * (index-1-stack.peek()); | ||
} | ||
return Math.max(max,area); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package com.Practice; | ||
|
||
import java.util.Arrays; | ||
|
||
public class MaxDifference { | ||
public static void main(String[] args) { | ||
int [] arr = {1,6,3,2}; | ||
Arrays.sort(arr); | ||
int maxDifference = arr[arr.length-1] - arr[0]; | ||
System.out.println(maxDifference); | ||
|
||
|
||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package com.Practice; | ||
|
||
public class MergeAlternateString { | ||
public static void main(String[] args) { | ||
//1768. Merge Strings Alternately | ||
|
||
} | ||
public static String mergeAlternately(String word1, String word2) { | ||
StringBuilder result = new StringBuilder(); | ||
int i = 0; | ||
while (i < word1.length() || i < word2.length()) { | ||
if (i < word1.length()) { | ||
result.append(word1.charAt(i)); | ||
} | ||
if (i < word2.length()) { | ||
result.append(word2.charAt(i)); | ||
// result.append | ||
} | ||
i++; | ||
} | ||
return result.toString(); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.Practice; | ||
|
||
import java.util.Arrays; | ||
|
||
public class MinDifference { | ||
public static void main(String[] args) { | ||
int [] arr = {90,80,70,75}; | ||
System.out.println(minDiff(arr,2)); | ||
} | ||
static int minDiff(int [] arr,int num){ | ||
if(arr.length == 1 || arr.length<num){ | ||
return 0; | ||
} | ||
Arrays.sort(arr); | ||
int j = num-1; | ||
int difference = Integer.MAX_VALUE; | ||
int temp; | ||
for(int i =0;i< arr.length && j< arr.length;i++,j++){ | ||
temp = arr[j] - arr[i]; | ||
if(difference > temp){ | ||
difference = temp; | ||
} | ||
} | ||
return difference; | ||
} | ||
} |
Oops, something went wrong.