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
// Protect the jQuery alias, $, from other Javascript libraries by extending it within a protected scope. | |
(function($) { | |
// Extend the jQuery library using the name of you plugin, in this case 'pluginName' | |
$.fn.pluginName = function(options) { | |
// Extend the options (a Javascript object) parameter with the default options declared further below | |
var $opts = $.extend({}, $.fn.pluginName.options, options); | |
// Public method (see below) | |
$.fn.pluginName.somePublicMethod(); | |
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
switch(var) { | |
case 1: | |
doSomething(); | |
break; | |
case 2: | |
doSomethingElse(); | |
break; | |
default: |
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
<IfModule pagespeed_module> | |
ModPagespeed off | |
</IfModule> |
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 TapeEquilibrium { | |
public int solution(int[] A) { | |
/* | |
* Declare some initial variables | |
* min is the maximum value an Integer could possibly be. (each element of array A is an integer within the range [−1,000..1,000].) | |
* total will represent the total value of each element in A | |
* upto will be used to represent the left hand side of the Array | |
*/ | |
int min = 9999, | |
total = 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
public class TapeEquilibrium { | |
public int solution(int[] A) { | |
/* | |
* Declare some initial variables | |
* min is the maximum value an Integer could possibly be. (each element of array A is an integer within the range [−1,000..1,000].) | |
* total will represent the total value of each element in A | |
* upto will be used to represent the left hand side of the Array | |
*/ | |
int min = 9999, | |
total = 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
A non-empty zero-indexed array A consisting of N integers is given. Array A represents numbers on a tape. | |
Any integer P, such that 0 < P < N, splits this tape into two non-empty parts: A[0], A[1], ..., A[P − 1] and A[P], A[P + 1], ..., A[N − 1]. | |
The difference between the two parts is the value of: |(A[0] + A[1] + ... + A[P − 1]) − (A[P] + A[P + 1] + ... + A[N − 1])| | |
In other words, it is the absolute difference between the sum of the first part and the sum of the second part. | |
For example, consider array A such that: | |
A[0] = 3 | |
A[1] = 1 | |
A[2] = 2 | |
A[3] = 4 |
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 FrogJump { | |
public int solution(int Y, int X, int D) { | |
/* | |
* jump_distance is the value | |
* jumps the number of jumps can be calculated by dividing the jump distance by the number of jumps, | |
* this won't calculate the total number of jumps, this can be calculated by using modulus, if there is a | |
* remainder 1 is added to the total number of jumps. | |
*/ | |
int jump_distance = (Y - X), | |
jumps = (jump_distance / D) + ((jump_distance % D > 0) ? 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
A small frog wants to get to the other side of the road. The frog is currently located at position X and wants to get to a position greater than or equal to Y. The small frog always jumps a fixed distance, D. | |
Count the minimal number of jumps that the small frog must perform to reach its target. | |
Write a function: | |
class Solution { public int solution(int X, int Y, int D); } | |
that, given three integers X, Y and D, returns the minimal number of jumps from position X to a position equal to or greater than Y. | |
For example, given: | |
X = 10 | |
Y = 85 | |
D = 30 | |
the function should return 3, because the frog will be positioned as follows: |
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
A zero-indexed array A consisting of N different integers is given. The array contains integers in the range [1..(N + 1)], which means that exactly one element is missing. | |
Your goal is to find that missing element. | |
Write a function: | |
class Solution { public int solution(int[] A); } | |
that, given a zero-indexed array A, returns the value of the missing element. | |
For example, given array A such that: | |
A[0] = 2 | |
A[1] = 3 | |
A[2] = 1 | |
A[3] = 5 |
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.Arrays; | |
/** | |
* Created by jordanterry on 26/10/14. | |
*/ | |
public class PermMissingElem { | |
public int Solution(int[] A) { | |
// If it is empty, return one, each permutation must start with 1 | |
if(A.length == 0) return 1; |
OlderNewer