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
package com.company; | |
import java.io.*; | |
import java.util.*; | |
import java.text.*; | |
import java.math.*; | |
import java.util.regex.*; | |
public class Calculator { | |
public static void main(String[] args) { |
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
package com.company; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.HashMap; | |
public class Application { | |
static Map<String, User> userStorage = new HashMap<>(); | |
public static void main(String[] args) { | |
System.out.println("****************Diamond Store************"); |
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
package com.company; | |
import java.io.*; | |
import java.util.*; | |
import java.text.*; | |
import java.lang.*; | |
import java.util.HashMap; | |
import java.util.Map; | |
import java.util.Scanner; | |
public class Application { |
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
class Solution { | |
public: | |
vector<int> twoSum(vector<int>& nums, int target) { | |
vector<int> arr; | |
for (int i=0; i < nums.size(); i++){ | |
int rem = target - nums[i]; | |
for (int j=0; j < nums.size(); j++){ | |
if (rem == nums[j] && j!=i){ | |
arr.push_back(i); | |
arr.push_back(j); |
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
class Solution { | |
public int[] twoSum(int[] nums, int target) { | |
Map<Integer, Integer> map = new HashMap<>(); | |
for (int i = 0; i < nums.length; i++) { | |
map.put(nums[i], i); | |
} | |
for (int i = 0; i < nums.length; i++) { | |
if (map.containsKey(target - nums[i]) && map.get(target - nums[i]) != i) { |
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
/** | |
* Definition for a binary tree node. | |
* public class TreeNode { | |
* int val; | |
* TreeNode left; | |
* TreeNode right; | |
* TreeNode(int x) { val = x; } | |
* } | |
*/ | |
class Solution { |
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
/** | |
* Definition for a binary tree node. | |
* public class TreeNode { | |
* int val; | |
* TreeNode left; | |
* TreeNode right; | |
* TreeNode(int x) { val = x; } | |
* } | |
*/ | |
class Solution { |
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
class Solution { | |
public int removeElement(int[] nums, int val) { | |
int i, count= 0; | |
for(i=0; i< nums.length; i++){ | |
if(nums[i] != val){ | |
nums[count] = nums[i]; | |
count++; | |
} | |
} | |
return count; |
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
class Solution { | |
public int removeDuplicates(int[] nums) { | |
int i=0; | |
int j=1; | |
int temp=1; | |
while(j<nums.length) | |
{ | |
if(nums[i]==nums[j]) | |
{ | |
j++; |
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
public class Solution { | |
public String longestCommonPrefix(String[] strs) { | |
if(strs.length==0||strs==null) return ""; | |
String prefix = strs[0]; | |
for(int i = 1;i<strs.length;i++){ | |
if(strs[i] == prefix) continue; | |
int k = 0; | |
while(k<prefix.length()&&k<strs[i].length()&&prefix.charAt(k)==strs[i].charAt(k)){ | |
k++; | |
} |
OlderNewer