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 numberOfSteps(int num) { | |
int steps = 0; | |
while (num > 0) { | |
steps++; | |
if((num & 1) == 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 { | |
public int numberOfSteps(int num) { | |
int steps = 0; | |
while (num > 0) { | |
steps += 1; | |
if(num % 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 { | |
public List<String> fizzBuzz(int n) { | |
List<String> results = new ArrayList<String>(); | |
for(int i = 1; i <= n; i++) { | |
String result = ""; | |
if(i % 3 == 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 { | |
public int maximumWealth(int[][] accounts) { | |
int maxWealth = 0; | |
for(int customer = 0; customer < accounts.length; customer ++) { | |
int wealth = this.sum(accounts[customer]); | |
maxWealth = Math.max(maxWealth, wealth); | |
} |
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[] runningSum(int[] nums) { | |
for(int i = 1; i < nums.length; i++) { | |
nums[i] = nums[i - 1] + nums[i]; | |
} | |
return nums; | |
} |
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 HelloWorld { | |
public static void main(String [] args) { | |
int[] input = { 41, 34, 45, 23, 67, 97 }; | |
int max = maximum(input); | |
System.out.println("Maximum = " + max); | |
} |
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
// JAVA QUICK REFERENCE - This is single line comment. | |
import java.util.Scanner; | |
/* This is a multi line comment | |
A public class named 'HelloWorld' */ | |
public class HelloWorld { | |
/* This is a 'public' & 'static' method. | |
Static method belongs to class, |
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
import java.util.HashMap; | |
public class Anagram { | |
public static void main(String [] args) { | |
boolean result = isAnagram("race", "care"); | |
System.out.println(result); | |
} |
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
// AMD, Node flavored CommonJS, and old fashion global | |
(function (global, factory) { | |
if (typeof define === 'function' && define.amd) { | |
// AMD. Register as an anonymous module. | |
define([], factory); | |
} else if (typeof exports === 'object') { | |
// Node. Does not work with strict CommonJS, but | |
// only CommonJS-like environments that support module.exports, | |
// like Node. | |
module.exports = factory(); |
NewerOlder