Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add files via upload #161

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 91 additions & 0 deletions Day1.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
//Separate White And Black balls
/**class Solution {
public long minimumSteps(String s) {
long swap = 0;
int black = 0;
for (int i = 0; i < s.length(); i++) {
if (s.charAt(i) == '0')
swap += (long) black;
else
black++;
}
return swap;
}
}*/

// Valid Anagram
/*class Solution {
public boolean isAnagram(String s, String t) {
int s1= s.length();
int t1 = t.length();
if(s1 != t1){
return false;
}
int[] arr = new int [26];
for(int i =0; i<s.length();i++){
arr[s.charAt(i) - 'a']++;

}
for(int i =0; i<t.length();i++){
arr[t.charAt(i) - 'a']--;
if(arr[t.charAt(i) - 'a'] < 0){
return false;
}

}

return true;
}
}*/


//Remove Dublicates from sorted list

/*class Solution {
public ListNode deleteDuplicates(ListNode head) {
if(head==null)
return head;
ListNode prev = head,curr = head.next;
while(curr!=null){
if(prev.val==curr.val){
prev.next = curr.next;
curr = curr.next;
}
else{
prev = curr;
curr = curr.next;
}
}

return head;

}
}*/

//Maximum Swap
/*class Solution {

public int maximumSwap(int num) {
String numStr = Integer.toString(num);
int n = numStr.length();
int maxNum = num;


for (int i = 0; i < n; ++i) {
for (int j = i + 1; j < n; ++j) {
char[] numeral = numStr.toCharArray();


char temp = numeral[i];
numeral[i] = numeral[j];
numeral[j] = temp;

int tempNum = Integer.parseInt(new String(numeral));
maxNum = Math.max(maxNum, tempNum);
}
}

return maxNum;
}
}
/* */
102 changes: 102 additions & 0 deletions Day2.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//Array Partition
/*class Solution {
public int arrayPairSum(int[] nums) {
int a =0;
Arrays.sort(nums);
for(int i=0; i<nums.length;i+=2){
a += nums[i];
}

return a;

}
}*/


//Find the difference

/*class Solution {
public char findTheDifference(String s, String t) {
char ans = 0;
for(char ch : s.toCharArray()){
ans ^= ch;

}
for(char ch : t.toCharArray()) {
ans ^= ch;
}
return ans;



}
}*/

//Intersection of two Arrays

/*class Solution {
public int[] intersection(int[] nums1, int[] nums2) {
HashSet<Integer> set = new HashSet<>();
for(int n2 : nums2){
set.add(n2);
}
ArrayList<Integer> list = new ArrayList<>();
for (int n1:nums1){
if(set.contains(n1)){
list.add(n1);
set.remove(n1);
}
}
int res[] = new int [list.size()];
for(int i = 0; i<list.size();i++){
res[i] = list.get(i);
}
return res;
}
}*/

// Assign Cookies
/*class Solution {
public int findContentChildren(int[] g, int[] s) {
Arrays.sort(g);
Arrays.sort(s);

int m = g.length;
int n = s.length;

int i = 0 , j= 0;
while( i< m && j<n){
if(g[i] <= s[j]){
i++;
}
j++;

}
return i;

}
}*/


//Buy two chocolets
/*class Solution {
public int buyChoco(int[] prices, int money) {
int first = 999;
int second = 999;
for(int price:prices)
{
if(price<=first){
second = first;
first = price;
}
else if(price < second )
second = price;
}
int total = first + second ;
if(total <=money)
return money-total;
else
return money;
}
}*/