Deprecated: Creation of dynamic property wpdb::$categories is deprecated in /home2/learnera/public_html/tech/wp-includes/wp-db.php on line 760

Deprecated: Creation of dynamic property wpdb::$post2cat is deprecated in /home2/learnera/public_html/tech/wp-includes/wp-db.php on line 760

Deprecated: Creation of dynamic property wpdb::$link2cat is deprecated in /home2/learnera/public_html/tech/wp-includes/wp-db.php on line 760

Deprecated: Creation of dynamic property WPtouchProFour::$settings_object is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/wptouch/core/class-wptouch-pro.php on line 82

Deprecated: Automatic conversion of false to array is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/wptouch/core/admin-load.php on line 70

Deprecated: Creation of dynamic property WP_Block_Type::$skip_inner_blocks is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block-type.php on line 391

Deprecated: Creation of dynamic property WP_Block_Type::$skip_inner_blocks is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block-type.php on line 391

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_classic_block is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 347

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_block is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 349

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$toolbar_block_side is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 350

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$panels_block is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 351

Deprecated: Creation of dynamic property Advanced_Editor_Tools::$used_block_buttons is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/tinymce-advanced/tinymce-advanced.php on line 354

Deprecated: Creation of dynamic property YARPP::$is_custom_template is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Core.php on line 56

Deprecated: Creation of dynamic property YARPP::$db_options is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Core.php on line 69

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Return type of Requests_Cookie_Jar::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Cookie/Jar.php on line 63

Deprecated: Return type of Requests_Cookie_Jar::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Cookie/Jar.php on line 73

Deprecated: Return type of Requests_Cookie_Jar::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Cookie/Jar.php on line 89

Deprecated: Return type of Requests_Cookie_Jar::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Cookie/Jar.php on line 102

Deprecated: Return type of Requests_Cookie_Jar::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Cookie/Jar.php on line 111

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetExists($key) should either be compatible with ArrayAccess::offsetExists(mixed $offset): bool, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 40

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetGet($key) should either be compatible with ArrayAccess::offsetGet(mixed $offset): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 51

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetSet($key, $value) should either be compatible with ArrayAccess::offsetSet(mixed $offset, mixed $value): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 68

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::offsetUnset($key) should either be compatible with ArrayAccess::offsetUnset(mixed $offset): void, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 82

Deprecated: Return type of Requests_Utility_CaseInsensitiveDictionary::getIterator() should either be compatible with IteratorAggregate::getIterator(): Traversable, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice in /home2/learnera/public_html/tech/wp-includes/Requests/Utility/CaseInsensitiveDictionary.php on line 91

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Warning: Cannot modify header information - headers already sent by (output started at /home2/learnera/public_html/tech/wp-includes/wp-db.php:760) in /home2/learnera/public_html/tech/wp-includes/feed-rss2.php on line 8
Rajesh https://tech.learnerandtutor.com A Developer Sat, 09 Jul 2022 14:19:29 +0000 en-US hourly 1 https://wordpress.org/?v=6.0.8 Arrays: Left Rotation https://tech.learnerandtutor.com/arrays-left-rotation/ https://tech.learnerandtutor.com/arrays-left-rotation/#respond Fri, 05 Feb 2021 01:00:00 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 383
https://learnerandtutor.com/?p=138 Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266
Problem A left rotation operation on an array shifts each of the array’s elements 1 unit to the left. For example, if 2 left rotations are performed on an array [1,2,3,4,5], then the array would become [3,4,5,1,2]. Note that the … Continue reading ]]>

Deprecated: Creation of dynamic property WP_Block::$attributes is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block.php on line 179

Deprecated: Creation of dynamic property WP_Block::$attributes is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block.php on line 179

Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Problem

A left rotation operation on an array shifts each of the array’s elements 1 unit to the left. For example, if 2 left rotations are performed on an array [1,2,3,4,5], then the array would become [3,4,5,1,2]. Note that the lowest index item move to the highest index in a rotation. This is called circular array.

Given an array a of n integers and a number, d perform d left rotations on the array. Return the updated array to be printer as a single line of space-separated integers.

Function Description

Complete the function rotLeft in the editor below.

rotLeft has the following parameter(s):

  • int a[n]: the array to rotate
  • int d: the number of rotations

Returns

  • int a'[n]: the rotated array

Input Format

  • The first line contains two space-separated integers n and d, the size of a and the number of left rotations.
  • The second line contains n space-separated integers, each an a[i]

Constraints

  • 1 <= n <= 105
  • 1 <= d <= n
  • 1 <= a[i] <=106

Solution

package org.span;

import java.io.IOException;

public class ArrayLeftRotation {

    static int[] rotLeft(int[] a, int d) {
        for (int i = 0; i < d; i++) {
            int t = a[0];
            System.arraycopy(a, 1, a, 0, a.length - 1);
            a[a.length - 1] = t;
        }
        return a;
    }

    public static void main(String[] args) throws IOException {
        int d = 4;
        int[] a = {1, 2, 3, 4, 5};
        int[] result = rotLeft(a, d);
        print(result);
    }


    public static void print(int[] a) {
        for (int i = 0; i < a.length; i++) {
            if (i > 0)
                System.out.print(" " + a[i]);
            else
                System.out.print(a[i]);
        }
    }

}
]]>
https://tech.learnerandtutor.com/arrays-left-rotation/feed/ 0
2D Array – DS – HourGlass https://tech.learnerandtutor.com/2d-array-ds-hourglass/ https://tech.learnerandtutor.com/2d-array-ds-hourglass/#respond Thu, 04 Feb 2021 01:00:00 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 383
https://learnerandtutor.com/?p=131 Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266
Problem Solution ]]>

Deprecated: Creation of dynamic property WP_Block::$attributes is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block.php on line 179

Deprecated: Creation of dynamic property WP_Block::$attributes is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block.php on line 179

Deprecated: Creation of dynamic property WP_Block::$attributes is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block.php on line 179

Deprecated: Creation of dynamic property WP_Block::$attributes is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block.php on line 179

Deprecated: Creation of dynamic property WP_Block::$attributes is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block.php on line 179

Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266
Problem

Solution

package org.span;

import java.io.IOException;
import java.util.Scanner;

public class HourGlass {

    static int hourglassSum(int[][] arr) {
        int max = -99999, cur;
        for (int i = 0; i < 4; i++) {
            for (int j = 0; j < 4; j++) {
                cur = arr[i][j] + arr[i][j + 1] + arr[i][j + 2] + arr[i + 1][j + 1] + arr[i + 2][j] + arr[i + 2][j + 1] + arr[i + 2][j + 2];
                if (cur > max) {
                    max = cur;
                }
            }
        }
        return max;
    }

    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) throws IOException {
        /*int[][] arr = {
                {1, 1, 1, 0, 0, 0},
                {0, 1, 0, 0, 0, 0},
                {1, 1, 1, 0, 0, 0},
                {0, 0, 2, 4, 4, 0},
                {0, 0, 0, 2, 0, 0},
                {0, 0, 1, 2, 4, 0}
        };*/
        int[][] arr = {
                {0, -4, -6, 0, -7, -6},
                {-1, -2, -6, -8, -3, -1},
                {-8, -4, -2, -8, -8, -6},
                {-3, -1, -2, -5, -7, -4},
                {-3, -5, -3, -6, -6, -6},
                {-3, -6, 0, -8, -6, -7},
        };
        int result = hourglassSum(arr);
        System.out.println(result);
    }
}

]]>
https://tech.learnerandtutor.com/2d-array-ds-hourglass/feed/ 0
Repeated String https://tech.learnerandtutor.com/repeated-string/ https://tech.learnerandtutor.com/repeated-string/#respond Wed, 03 Feb 2021 01:00:00 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 383
https://learnerandtutor.com/?p=125 Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266
Problem Solution ]]>

Deprecated: Creation of dynamic property WP_Block::$attributes is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block.php on line 179

Deprecated: Creation of dynamic property WP_Block::$attributes is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block.php on line 179

Deprecated: Creation of dynamic property WP_Block::$attributes is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block.php on line 179

Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266
Problem

Solution

import java.io.IOException;

public class RepeatedString {
    static long repeatedString(String s, long n) {
        long noOfOccurence = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) == 'a')
                noOfOccurence++;
        }
        long repeat = n / s.length();
        noOfOccurence *= repeat;
        for (int i = 0; i < n % s.length(); i++) {
            if (s.charAt(i) == 'a')
                noOfOccurence++;
        }
        return noOfOccurence;
    }

    public static void main(String[] args) throws IOException {
        String s = "aba";
        long n = 10;
        long result = repeatedString(s, n);
        System.out.println(result);
    }
}
]]>
https://tech.learnerandtutor.com/repeated-string/feed/ 0
Jumping on the Clouds https://tech.learnerandtutor.com/jumping-on-the-clouds/ https://tech.learnerandtutor.com/jumping-on-the-clouds/#respond Tue, 02 Feb 2021 01:00:00 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 383
https://learnerandtutor.com/?p=111 Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266
Problem Solution ]]>

Deprecated: Creation of dynamic property WP_Block::$attributes is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block.php on line 179

Deprecated: Creation of dynamic property WP_Block::$attributes is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block.php on line 179

Deprecated: Creation of dynamic property WP_Block::$attributes is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block.php on line 179

Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266
Problem

Solution

import java.io.IOException;

public class JumpingOnClouds {
    static int jumpingOnClouds(int[] c) {
        int jumps = 0;
        for (int i = 0; i < c.length; ) {
            if (i + 2 < c.length && c[i + 2] == 0)
                i += 2;
            else
                i++;
            jumps++;
        }
        return jumps - 1;
    }

    public static void main(String[] args) throws IOException {
        int[] c = {0, 0, 1, 0, 0, 1, 0};
        int result = jumpingOnClouds(c);
        System.out.println(result);
    }
}
]]>
https://tech.learnerandtutor.com/jumping-on-the-clouds/feed/ 0
Counting Valleys https://tech.learnerandtutor.com/counting-valleys/ https://tech.learnerandtutor.com/counting-valleys/#respond Mon, 01 Feb 2021 01:00:00 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 383
https://learnerandtutor.com/?p=107 Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266
Problem Solution ]]>

Deprecated: Creation of dynamic property WP_Block::$attributes is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block.php on line 179

Deprecated: Creation of dynamic property WP_Block::$attributes is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block.php on line 179

Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266
Problem

Solution

import java.io.IOException;

class Result {
    public static int countingValleys(int steps, String path) {
        int valleyCount = 0, prePos, pos = 0;
        for (int i = 0; i < steps; i++) {
            prePos = pos;
            if (path.charAt(i) == 'D')
                pos--;
            else
                pos++;
            if (pos == 0 & prePos < 0)
                valleyCount++;
        }
        return valleyCount;
    }
}

public class CountingValleys {
    public static void main(String[] args) throws IOException {
        int steps = 8;
        String path = "UDDDUDUU";
        int result = Result.countingValleys(steps, path);
        System.out.println(result);
    }
}

]]>
https://tech.learnerandtutor.com/counting-valleys/feed/ 0
Sales by Match https://tech.learnerandtutor.com/sales-by-match/ https://tech.learnerandtutor.com/sales-by-match/#respond Tue, 12 Jan 2021 10:30:49 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 383
https://learnerandtutor.com/?p=96 Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266
Problem Alex works at a clothing store. There is a large pile of socks that must be paired by color for sale.Given an array of integers representing the color of each sock, determine how many pairs of socks with matching … Continue reading ]]>

Deprecated: Creation of dynamic property WP_Block::$attributes is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-block.php on line 179

Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266
Problem

Alex works at a clothing store. There is a large pile of socks that must be paired by color for sale.
Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are.

For example, there are n=7 socks with colors ar = [1,2,1,2,1,3,2] .
There is one pair of color 1 and one of color 2.
There are three odd socks left, one of each color. The number of pairs is 2.

Function Description
Complete the sockMerchant function in the editor below.
It must return an integer representing the number of matching pairs of socks that are available.

sockMerchant has the following parameter(s):
n: the number of socks in the pile
ar: the colors of each sock

Input Format
The first line contains an integer n, the number of socks represented in ar.
The second line contains n space-separated integers describing the colors ar[i] of the socks in the pile.

Constraints
1 <= n <= 100
1 <= ar[i] <= 100 where 0 <= i < n

Output Format
Return the total number of matching pairs of socks that Alex can sell.

Sample Input
9
10 20 20 10 10 30 50 10 20

Sample Output
3

Alex can match three pairs of socks

Solution

import java.util.HashMap;
import java.util.Scanner;

public class PairOfSocks {
    static int sockMerchant(int n, int[] ar) {
        HashMap<Integer, Integer> colorsMap = new HashMap<>();
        for (int color : ar) {
            colorsMap.put(color, (colorsMap.getOrDefault(color, 0)) + 1);
        }
        final int[] totalPair = {0};
        colorsMap.forEach((key, value) -> totalPair[0] += value / 2);
        return totalPair[0];
    }

    private static final Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");
        int[] ar = new int[n];
        String[] arItems = scanner.nextLine().split(" ");
        scanner.skip("(\r\n|[\n\r\u2028\u2029\u0085])?");

        for (int i = 0; i < n; i++) {
            int arItem = Integer.parseInt(arItems[i]);
            ar[i] = arItem;
        }
        int result = sockMerchant(n, ar);
        System.out.println(result);
        scanner.close();
    }
}

Explanation

We need to find no of pairs for each number. We can add the quantity of each number into a map. Then we can divide the values by 2 and sum up to get the final answer.

]]>
https://tech.learnerandtutor.com/sales-by-match/feed/ 0
A journey to learn https://tech.learnerandtutor.com/a-journey/ https://tech.learnerandtutor.com/a-journey/#respond Mon, 04 Jan 2021 16:58:36 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 383
https://learnerandtutor.com/?p=1 Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266
Few months back I came to know about the book ‘Cracking the Coding Interview’ by ‘Gayle Laakmann McDowell‘. The book is mainly about the interview process of top companies and 189 programming questions to crack those interviews. The reviews about … Continue reading ]]>

Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266
Few months back I came to know about the book ‘Cracking the Coding Interview’ by ‘Gayle Laakmann McDowell‘. The book is mainly about the interview process of top companies and 189 programming questions to crack those interviews. The reviews about this book were good as well. So I thought of reading this book. So I ordered through amazon.

I received the book few weeks later and kept it in the book-shelf. I didn’t read it. On this 2021 new year suddenly I got a spark. Why don’t we read this book now and write about those learning as posts in a blog?

The outcome is this blog. The idea is simple. I will read this book and explore all the coding challenges from this book. Whatever I learn, will post it here. So that interested programmers either they are preparing for interviews or learning on their own may benefit.

Thanks.

]]>
https://tech.learnerandtutor.com/a-journey/feed/ 0
Spring Web Flow – Concepts [Part 1] https://tech.learnerandtutor.com/spring-web-flow-concepts-part-1/ https://tech.learnerandtutor.com/spring-web-flow-concepts-part-1/#respond Tue, 17 Apr 2018 15:42:20 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 383

Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 383
http://tech.learnerandtutor.com/?p=646 Continue reading ]]> In this post we will see the major concepts relates to Spring web flow. Spring flow is an approach to implement multi page flow web applications like shopping portal.  For example in shopping portal application a user may involve in the below steps.

  1. Login to the application
  2. Surf among the products
  3. Add needed products to the cart
  4. view/edit cart if needed
  5. Click checkout
  6. Provide contact information
  7. Payment
  8. End

As there are multiple pages involved in the shopping flow, the data needs to be carried throughout multiple pages. If we handle this task manually it will be tedious task. We will go out of our indented business logic. To implement these kinds of tasks easily Spring provides the web flow framework.

A flow is nothing but a set of tasks to be done in a particular order. In webflow it is an xml file which tells the exactly how this flow should works. If we configure our application flow in spring web flow, the data carrying portion as well as the page navigation issues will be taken care by spring web flow itself. We can concentrate on our business logic rather than spending time on working those mundane tasks.

Spring web flow can be configured only via xml file. Currently it is not feasible to configure via only java.

The first thing to setup a web flow is configuration. A flow configuration involves below major components. Let’s go through them.

Flow executor: Flow executor is responsible to drive the flow.  The syntax will be like below.

<flow:flow-executor id="flowExecutor"/>

Flow Registry: Flow registry is responsible to load the flow definitions. For example if all flows under folder WEB-INF/flows needs to be loaded it has to be configured like  below.

<flow:flow-registry id="flowRegistry" base-path="/WEB-INF/flows">
<flow:flow-location-pattern value = "**/*-flow.xml"/> 
</flow:flow-registry>

Here one important thing to note is the url path to the flow will be determined by the path of the flow location.  For example if the path of a flow is /WEB-INF/flows/order/order-flow.xml  then the id will be order  (relative to the base path.) So the flow will be triggered while accessing the url http://{url}/{contextpath}/order

Instead of the pattern the path of the flow file also can be configured. For example to load order-flow.xml flow it can be configured like below.

<flow:flow-registry id="flowRegistry"> <flow:flow-location path = "/WEB-INF/flows/order/order-flow.xml"/> </flow:flow-registry>

If the full path is specified then the filename will become the id of that flow. In the above case it will be order-flow . If id needs to be different from the path it can be specified with id attribute like below.

<flow:flow-location path = "/WEB-INF/flows/order/order-flow.xml" id="custom/path/flow"/>

As per the above code the flow will be triggered when the url {contextPath}/custom/path/ flow is entered.

Flow Handler Mapping : Like DispatcherServlet  for controller mapping, there is a class FlowHandlerMapping  for URL to flow mapping for web flow.

Flow Handler Adapter : Like Controllers for handling the requests, there is a class FlowHandlerAdapter  to handle the flow requests

The next important thing is the flow.  A Flow is an xml file which tells the exactly how this flow should works. A flow will have three major components.

  1. State
  2. Transition
  3. Data

State : As per the name it is the state of the flow, which means the flows should be in a state.  There are five types of states possible.

  1. View-state
    • To display some pages to the user
    • <view-state id=”welcome”/> will redirect to the view named welcome
    • <view-state id=”welcome” view=”success”/> will redirect to the view named success
    • <view-state id=”welcome” view=”success” model=”flowScope.paymentDetails”/> will redirect to the view named  success  with model attribute paymentDetails 

  2. Action-state
    • To execute logical conditions. The syntax will be like below.
      <action-state id="saveOrder">
          <evaluate expression="pizzaFlowActions.saveOrder(order)"/>
          <transition to="thankYou"/>
      </action-state>
    • When flow reaches  the above state the method pizzaFlowActions.saveOrder(order)  will be executed and once done thankYou  state will be invoked.
  3. Decision-state
    • To decide which path to proceed based on particular condition. Can be of only two paths. Either True or false
      <decision-state id="checkDeliveryArea">
          <if test="pizzaFlowActions.checkDeliveryArea(customer.zipCode)" 
          then="addCustomer" else="deliveryWarning"/>
      </decision-state>
  4. Subflow-state
    • To trigger a sub-flow from the current flow. Once the sub-flow ends the current flow will resume
      <subflow-state id="order" subflow="pizza/order">
          <input name="order" value="order"/>
          <transition on="orderCreated" to="payment"/>
      </subflow-state>
  5. End-state
    • To denote the end of the flow. Syntax will be like below.
    • <end-state id=”customerReady”/>
    • If this is the sub flow the parent flow will resume once this flow ends.
    • If this is not sub flow and has a view it will be rendered.
    • If view name is prefixed with externalRedirect:  it will redirect to that page outside the flow
    • If view name is prefixed with flowRedirect:  it will redirect to that page to another flow
    • If this is not sub flow and there is no view, then the flow will end and go to the first state of the flow as a new flow.

Transition: To move from one state to another state the transition element will be used.

  • It will be child element of the state elements view-state,subflow-state or action-state. The syntax will be like below.
  • <transition to=”customerReady”>  – If no on event is attached, it will be the default transition.
  • <transition on=”submit” to=”customerReady”>  – On submit event it will be fired
  • <transition on-exception=”org.span.server.UserNotFoundException” to=”registrationForm”>  – On UserNotfoundException  this event will be fired.
  •  Instead of repeating same transitions on multiple states we can use global transitions like below. It will be applied to all states by default.
    <global-transitions>
       <transition on="cancel" to="endState"/>
    </global-transitions>

Data: To store and pass data through out the flow the data elements will be used. The syntax will be <var name=”customer” class=”org.span.domain.Customer”/>

  • In the above example a new Customer object will be created and assigned to customer. Also will be available across all state in that flow
  • Also <evaluate>  can be used on a view state or action state like below
  • <evaluate result=”viewScope.toppingsList” expression=”T(org.span.domain.pizza.Topping).asList()”/>
  • Also <set>  can be used to set a variable’s value.
  • <set name=”flowScope.pizza” value=”new org.span.domain.Pizza()”/>
  • We can set the scope of the variables. It can be any one of the five types as below
    1. Conversion Scope     ->     Created at the top level and destroyed when top flow ends. Available under all sub flows too.
    2. Flow Scope               ->     Created at the flow level and available only within that level
    3. Request Scope         ->     Created when a request is made into a flow and destroyed when the flow returns
    4. Flash Scope              ->     Created when a flow starts and destroyed when flow ends. It is also cleared when a view state is rendered
    5. View Scope               ->     Created when a view state is entered, and destroyed when the state exists. Visible only to the view state.
  • Default scope of variable declared via <var>  tag will be flow scope.
  • Default scope of variable declared via <set> ,<evaluate>  will be mentioned along with the variable name like <set name=”flowScope.totalMarks” value=”499″/>

That is all about the major components of the web flow. Also web flow can be secured as well. To secure a flow it has to be configured like below.

<view-state id="restricted" view="paymentdetails">
    <secured attributes="ROLE_ADMIN,ROLE_FINANCE" match="all"/>
</view-state>

attributes  are comma separated roles. match  can be ‘any’ – At least one role required  or ‘all’ – All roles required .

In this section we have discussed the concepts of Spring web flow. In the next tutorial we will implement a simple web flow application to understand all the discussed concepts.

]]>
https://tech.learnerandtutor.com/spring-web-flow-concepts-part-1/feed/ 0
Useful SVN Commands https://tech.learnerandtutor.com/useful-svn-commands/ https://tech.learnerandtutor.com/useful-svn-commands/#respond Tue, 16 Jun 2015 03:37:27 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 383
http://tech.learnerandtutor.com/?p=597 Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118

Deprecated: Creation of dynamic property WP_Term::$object_id is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-term-query.php on line 1118
svnadmin create REPOS_PATH - Create a new repositiry in the REPOS_PATH svnadmin create --fs-type fsfs /var/svn/repos - Create a new repositiry in the REPOS_PATH using fsfs system svnadmin create --fs-type bdb /var/svn/repos - Create a new repositiry in the REPOS_PATH … Continue reading ]]>

Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266
svnadmin create REPOS_PATH - Create a new repositiry in the REPOS_PATH svnadmin create --fs-type fsfs /var/svn/repos - Create a new repositiry in the REPOS_PATH using fsfs system svnadmin create --fs-type bdb /var/svn/repos - Create a new repositiry in the REPOS_PATH using bdb system fsfs system - Changes noted against previous version bdb system - Changes noted against from initial version svn checkout URL - Creat a working copy of a repository svn add filename - To add file to working copy svn delete filename - To remove file from working copy svn copy foo bar - To make a copy of foo to bar and save it as svn change svn move foo bar - svn copy foo bar + svn delete foo svn mkdir dirname - To create a directory under working copy svn commit - Save the changes to svn repository with new revision svn commit --depth empty - Same as commit but only update the changes in the current level svn commit -m "message" - Same as commit but commits with message svn commit -f messageFile - Same as commit but commits with messag in messageFile svn update - Update Current working copy (Current path only, if need full update go to working copy home path) with HEAD version (U-updated, G-merged, C-Conflict) During conflict we can postpone the action. It will create multiple files with revision numbers. But before next commit have to resolve, otherwise cannot commit. svn resolve - If we postponed any conflicts to do svn resolve --accept working filename - accept my changed file as final copy and resolve svn resolve --accept theirs-full filename - accept HEAD version changed file as final copy and resolve svn status - Show the changes in the working copy from the initial checkout (No need connection to repository, with the help of .svn directory will be found) m-modified, a-added, d-deleted,c-conflict,?-not_in_svn svn status -v - Show all files versions even there is no change. svn status -v -u - Show all files versions by comparing with the repository HEAD version (Required connectivity to repository, * means change made to that file after checkout) svn diff - Show the content changes in detail for each file. (- deleted, + added) svn log - Shows comlete list of changes made to each revision for all files given file svn annotate filename - Full History of changes made to a file in line by line. svn revert filename - Revert the changes to working copy initial version. svn revert addedFile - Remove from Working Copy (check with svn status). svn revert deletedFile - Add back to Working Copy (check with svn status).

SVN Serve Setup

Note 1:
If we directly add directory or file to the working copy it will not be added to the repository when we commit. So either create directory or files directly the use command svn add file/directory name or create using svn add/ svn mkdir.

]]>
https://tech.learnerandtutor.com/useful-svn-commands/feed/ 0
Sublime Text 3 Shortcuts https://tech.learnerandtutor.com/sublime-text-3-shortcuts/ https://tech.learnerandtutor.com/sublime-text-3-shortcuts/#respond Tue, 16 Jun 2015 02:42:06 +0000
Deprecated: Creation of dynamic property WP_Term::$cat_ID is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 378

Deprecated: Creation of dynamic property WP_Term::$category_count is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 379

Deprecated: Creation of dynamic property WP_Term::$category_description is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 380

Deprecated: Creation of dynamic property WP_Term::$cat_name is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 381

Deprecated: Creation of dynamic property WP_Term::$category_nicename is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 382

Deprecated: Creation of dynamic property WP_Term::$category_parent is deprecated in /home2/learnera/public_html/tech/wp-includes/category.php on line 383
http://tech.learnerandtutor.com/?p=595 Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266
Recently I came across this post for sublime Text 3 shortcuts. A very useful post. Sublime Text 3 Shortcuts ]]>

Deprecated: Creation of dynamic property WP_Query::$yarpp_cache_type is deprecated in /home2/learnera/public_html/tech/wp-content/plugins/yet-another-related-posts-plugin/classes/YARPP_Cache.php on line 30

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266

Deprecated: Creation of dynamic property WP_Post::$score is deprecated in /home2/learnera/public_html/tech/wp-includes/class-wp-post.php on line 266
Recently I came across this post for sublime Text 3 shortcuts. A very useful post.

Sublime Text 3 Shortcuts

]]>
https://tech.learnerandtutor.com/sublime-text-3-shortcuts/feed/ 0