Posts

Showing posts from September, 2014

JAVA - Codility PermCheck test 100% score

Solution to Codility PermCheck Problem at:

https://codility.com/c/intro/demoJH2RM2-UZ8class Solution { public static void main(String[] args) { int A[] = {4, 1, 3, 2}; //int A[] = {4, 4, 3, 2}; //int A[] = {4, 3, 2}; //int A[] = {}; //int A[] = {1000000000, 3, 2}; //int A[] = {1000000000, 1000000001, 1000000002}; //int A[] = new int[100000]; System.out.println(solution(A)); } public static int solution(int[] A) { int result = 0; int size = A.length; int[] B = new int[A.length]; if(size == 0) return 0; for(int i=0; i<A.length; i++){ if(A[i]>size) return result; if(A[i]<1) return result; if(B[A[i]-1] == -1) return result; else B[A[i]-1] = -1; } return 1; } }

JAVA - Codility FrogRiverOne test 100% score

class Solution {
        public int solution(int X, int[] A) {
            // write your code in Java SE 8
            int numberOfPositions = 0;
            int result = -1;
            int[] array = new int[X];
            int index = 0;

            // Initialize array
            for (int i : array) {
                array[index] = -1;
                index++;
            }

            index = 0;
            for (int i : A) {
                try {
                    if (array[i - 1] == -1) {
                        array[i - 1] = index;
                        numberOfPositions++;
                        if (index > result)
                            result = index;
                        if (X == numberOfPositions) {
                            break;
                        }
                        index++;
                    } else {
                        index++;
                        continue;
                    }
                } catch (Exception e) {
                    index++;
           …

JAVA - Codility Equilibrium test 100% score

My solution:

class Solution { publicintsolution(int[] B) {// write your code in Java SE 8long[] rightToLeft = newlong[A.length];long[] leftToRight = newlong[A.length];long[] A = newlong[B.length];int result = -1;   // Convert int array to long array int j = 0;for (int value : B) { A[j++] = (long)value; }for(int i=0; i<rightToLeft.length; i++){if(i==0){ rightToLeft[i] = A[i]; } else { rightToLeft[i] = A[i] + rightToLeft[i-1]; } }for(int i=leftToRight.length-1; i>=0; i--){if(i==leftToRight.length-1){ leftToRight[i] = A[i]; } else { leftToRight[i] = A[i] + leftToRight[i+1]; } }for(int i=0; i<rightToLeft.length; i++){if(rightToLeft[i] == leftToRight[i]) { result = i;break; } }return result; }}

APEX - Error saving column settings with ORA-01403: no data found Error

Image
Problem:

While working with the report source and column names somehow it became "corrupted", it was impossible to change the name of one of the columns though possible to update the source and the rest of column names:

While saving the report APEX was showing the bellow error:

   Error saving column settings with ORA-01403: no data found Error

Solution:

Try to force APEX to refresh the column names by selection:

(this action will erase all existing column names)

   Use Generic Column Names (parse query at runtime only)


Hostmonster - 403 Permission denied (htaccess)

Are you getting the error "403 Permission denied" when trying to access your website from a single location?

Try the following:
Go to Google and search for "what is my ip"Get the ip returned by your search queryAccess your cpanel and go to your home or "public_html" folderBackup the .htaccess file to ,htaccess_oldOpen .htaccessSearch for any entry related to your ip (search for a few numbers only if the full ip is not found)Comment with the character "#" any line blocking your ipSave the file In my case i had to comment the following lines:

        # SetEnvIF REMOTE_ADDR "^xx\.xxx\.xxx\.xxx$" DenyAccess
        # SetEnvIF X-FORWARDED-FOR "^xx\.xxx\.xxx\.xxx$" DenyAccess
        # SetEnvIF X-CLUSTER-CLIENT-IP "^xx\.xxx\.xxx\.xxx" DenyAccess
        # deny from xx.xxx.xxx.xxx

APEX - Dynamic actions "in list" condition not working

Problem:

While setting an APEX dynamic action with the condition "in list" the system is ignoring the last element.

MANAGER,ADMIN

Solution:

Though the user manual states that the elements in the list must be comma separated it omits the fact that it must also end with comma.

   MANAGER,ADMIN,

JAVA - Introduce Line break in request

In the example bellow the recipe description had something like:

    100ml milk\r\n10g sugar

which in html corresponded to the following textarea contents:

    100ml milk
    10g sugar

    @RequestMapping("/submitRecipe")
    public String submitRecipe2(Model model, @ModelAttribute Recipe recipe, HttpServletRequest request) {
        model.addAttribute("recipe", recipe.getDescription().replace("\r\n", "%0A"));
        return "result2";
    }