Skip to content

Commit 4883f24

Browse files
committed
Uploaded Java Solution
1 parent 2f2346c commit 4883f24

File tree

6 files changed

+9
-4
lines changed

6 files changed

+9
-4
lines changed

Java/soln-array-problems/majority-element.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@author Farheen Bano
33
44
Reference-
5+
https://www.interviewbit.com/problems/majority-element/
56
https://leetcode.com/problems/majority-element/
67
*/
78

Java/soln-backtracking-problems/combination-sum-ii.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,18 @@ public List<List<Integer>> combinationSum2(int[] candidates, int target) {
1515
}
1616

1717
public void generateSubsets(int index, int[] candidates, List<Integer> cur, List<List<Integer>> subsets, int target){
18-
if(target==0){
18+
if(target==0) {
1919
subsets.add(new ArrayList<>(cur));
2020
return;
2121
}
2222

2323
if(target<0)
2424
return;
2525

26-
for(int i=index;i<candidates.length;i++){
26+
for(int i=index;i<candidates.length;i++) {
2727
if(i>index && candidates[i]==candidates[i-1])
2828
continue;
29+
2930
cur.add(candidates[i]);
3031
generateSubsets(i+1,candidates,cur,subsets,target-candidates[i]);
3132
cur.remove(cur.size()-1);

Java/soln-dynamic-programming-problems/longest-increasing-subsequence.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@author Farheen Bano
33
44
References-
5+
https://www.interviewbit.com/problems/longest-increasing-subsequence
56
https://www.geeksforgeeks.org/longest-increasing-subsequence-dp-3/
67
https://leetcode.com/problems/longest-increasing-subsequence/
78
*/

Java/soln-dynamic-programming-problems/longest-palindromic-subsequence.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ public int longestCommonSubsequence(String text1, String text2) {
3333
for(int j=0;j<=m;j++){
3434
if(i==0 || j==0)
3535
dp[i][j]=0;
36-
else if(str1[i-1]==str2[j-1]){
36+
else if(str1[i-1]==str2[j-1])
3737
dp[i][j]=1+dp[i-1][j-1];
38-
}
38+
3939
else
4040
dp[i][j]=Math.max(dp[i][j-1],dp[i-1][j]);
4141
}

Java/soln-grid-problems/DP-unique-paths-with-obstacle-grid.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
@author Farheen Bano
33
44
Reference-
5+
https://www.interviewbit.com/problems/unique-paths-in-a-grid
56
https://leetcode.com/problems/unique-paths-ii/
67
*/
78

Java/soln-string-problems/palindrome-longest-build.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ public int longestPalindrome(String s) {
2222
if(map.get(key)%2!=0)
2323
flag++;
2424
}
25+
2526
return flag>0?s.length()-flag+1:s.length();
2627
}
2728
}

0 commit comments

Comments
 (0)