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 project1; | |
import java.io.UnsupportedEncodingException; | |
import java.text.SimpleDateFormat; | |
import java.util.Date; | |
import java.util.HashMap; | |
import java.net.URLEncoder; |
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[] solution(int N, int[] A) { | |
int[] counters = new int[N]; | |
int max = 0; | |
int absMax = 0; | |
for (int i=0; i<A.length; i++) { | |
if (A[i] == N+1) { | |
if ((i < A.length-1 && A[i+1] != N+1) || (i==A.length-1)) { | |
absMax += 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
class Solution { | |
public int solution(int A, int B, int K) { | |
return B/K - A/K + ((A % K == 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
// simplier solution and neater | |
class Solution { | |
public int solution(int[] A, int[] B) { | |
int[] dFish = new int[A.length]; | |
int di = -1; | |
int upstreamCount = 0; | |
for (int i=0; i<A.length; i++) { | |
if (B[i] == 1) { | |
dFish[++di] = A[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
/* | |
We should travel the array twice. | |
For the first travel, we compute and record the maximum sub-array sum, which ends at each position. | |
At the second reverse travel, we compute and record the maximum sub-array sum, which starts at each position. | |
Finally, we combine two sub-arrays into one double slice, and find out the maximum sum. | |
*/ | |
class Solution { | |
public int solution(int[] A) { | |
int[] a = new int[A.length]; |
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 solution(int[] A) { | |
int[] a = new int[A.length]; | |
int peak = -1; | |
for (int i=0; i<A.length; i++) { | |
if (i > 0 && i < A.length-1) | |
if (A[i] > A[i-1] && A[i] > A[i+1]) | |
peak = i; | |
a[i] = peak; |
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; | |
class Solution { | |
public int[] solution(int[] A) { | |
HashMap<Integer, Integer> map = new HashMap<Integer, Integer>(); | |
HashMap<Integer, Integer> resmap = new HashMap<Integer, Integer>(); | |
int[] res = new int[A.length]; | |
for (int i=0; i<A.length; i++) { | |
int count = 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 { | |
public int solution(int[] A, int[] B) { | |
int pairs = 0; | |
for (int i=0; i<A.length; i++) | |
if (commonPrimeDivisors(A[i], B[i])) | |
pairs++; | |
return pairs; | |
} | |
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
// i and j current coordinates of the point | |
// a is two-dimensional array of points | |
// n is rows number | |
// m is columns number | |
// point is a number: 0 - free, 1 - block, 2 - path | |
// directions: | |
// 0 - left | |
// 1 - up | |
// 2 - right |
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
<?xml version="1.0" encoding="utf-8" ?> | |
<WebMessageTables xmlns:sawm="com.siebel.analytics.web/message/v1"> | |
<WebMessageTable lang="en-us" system="WriteBack" table="Messages"> | |
<WebMessage name="testExecute"> | |
<XML> | |
<writeBack connectionPool="cp_logistics_write_back"> | |
<insert> </insert> | |
<update> call execute_test() </update> | |
</writeBack> | |
</XML> |
OlderNewer