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 int finalValueAfterOperations(String[] operations) { | |
int x = 0; | |
for (String indivString : operations) { | |
if (indivString.contains("+")) { | |
x = x + 1; | |
} else { | |
x = x - 1; | |
} | |
} | |
return x; |
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 scratch { | |
public static void main(String[] args) { | |
System.out.println(new scratch().defangIPaddr("1.1.1.1")); | |
System.out.println(new scratch().sum(5, 6)); | |
System.out.println(new scratch().size("Hello")); | |
} | |
public String defangIPaddr(String address) { | |
String answer = address.replace(".", "[.]"); |
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: | |
def numUniqueEmails(self, emails: List[str]) -> int: | |
uniqueEmails = set(); | |
ans = 0; | |
for indivString in emails: | |
uniqueEmails.add( | |
indivString.split("@")[0].split("+")[0].replace(".", "") + "@" + indivString.split("@")[1]); |
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: | |
def findNumbers(self, nums: List[int]) -> int: | |
ans = 0; | |
for indivNum in nums: | |
digitsInIndivNum = 0; | |
while (indivNum != 0): | |
indivNum = int(indivNum / 10); | |
digitsInIndivNum += 1; | |
if (digitsInIndivNum % 2 == 0): |
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: | |
def sumZero(self, n: int) -> List[int]: | |
ans = []; | |
subtract = 0; | |
while (len(ans) < n - 1): | |
numToAdd = n - subtract; | |
ans.append(numToAdd) | |
ans.append(numToAdd * -1) | |
subtract += 1; |
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 Fida; | |
public class basic { | |
public static void main(String[] args) { | |
int[] numbers = {23, 231, 64, 7, 324}; | |
int sum = 0; | |
for(int i = 0; i < numbers.length; i++){ | |
System.out.println(numbers[i]); | |
sum = sum + numbers[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
s = "abccbaacz"; | |
lowestIndexOfSecond = len(s); | |
for i in range(0, len(s)): | |
currentVal = s[i]; | |
currentIndexOfSecond = len(s); | |
for j in range(i + 1, len(s)): | |
if (s[j] == currentVal): | |
currentIndexOfSecond = 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: | |
def digitCount(self, num: str) -> bool: | |
for i in range(0, len(num)): | |
currentNum = num[i]; | |
currentCount = 0; | |
expectedCounter = int(currentNum); | |
for j in num: | |
if (j == str(i)): | |
currentCount += 1; |
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 String decodeMessageBeter(String key, String message) { | |
Map<Character, Character> noDuplicates = new LinkedHashMap<>(); | |
key = key.replaceAll(" ", ""); | |
int initialAscii = 97; | |
for(char indivChar : key.toCharArray()){ | |
if(noDuplicates.get(indivChar) == null) { | |
noDuplicates.put(indivChar, (char) (initialAscii)); |
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
function generateRandomString(length) { | |
for(var i = 0; i < length; i++){ | |
var letterToAppend = Math.ceil(Math.random() * 26); //will return a number between 1 - 26 | |
if(Math.floor(Math.random() * 10) % 2 == 0){ | |
letterToAppend += 96; | |
} else { | |
letterToAppend += 64; | |
} | |
randomString += (String.fromCharCode(letterToAppend)); |
NewerOlder