Jerad  Bailey

Jerad Bailey

1598123760

Maximum value of expression (arr[i] + arr[j] * arr[k]) valid Triplet

Given an array  arr[] of N integers. The task is to find the maximum value of (arr[i] + arr[j] * arr[k]) among every triplet (i, j, k) such that arr[i] < arr[j] < arr[k] and i < j < k. If there doesn’t exist any such triplets then print “-1″.

Examples:

Input:_ arr[]={7, 9, 3, 8, 11, 10}_

Output:_ 106_

Explanation:

The valid triplets are:

1) (7, 9, 11), and value of (arr[i] + arr[j] * arr[k]) is 106.

2) (7, 9, 10), and value of (arr[i] + arr[j] * arr[k]) is 97.

3) (7, 8, 10), and value of (arr[i] + arr[j] * arr[k]) is 87.

4) (7, 8, 11), and value of (arr[i] + arr[j] * arr[k]) is 105.

5) (3, 8, 10), and value of (arr[i] + arr[j] * arr[k]) is 83.

6) (3, 8, 11), and value of (arr[i] + arr[j] * arr[k]) is 91.

Therefore, the maximum among the values is 106

Input:_ arr[]={1, 2, 3}_

Output:_ 7_

#arrays #mathematical #java-treeset

What is GEEK

Buddha Community

Maximum value of expression (arr[i] + arr[j] * arr[k]) valid Triplet
Jerad  Bailey

Jerad Bailey

1598123760

Maximum value of expression (arr[i] + arr[j] * arr[k]) valid Triplet

Given an array  arr[] of N integers. The task is to find the maximum value of (arr[i] + arr[j] * arr[k]) among every triplet (i, j, k) such that arr[i] < arr[j] < arr[k] and i < j < k. If there doesn’t exist any such triplets then print “-1″.

Examples:

Input:_ arr[]={7, 9, 3, 8, 11, 10}_

Output:_ 106_

Explanation:

The valid triplets are:

1) (7, 9, 11), and value of (arr[i] + arr[j] * arr[k]) is 106.

2) (7, 9, 10), and value of (arr[i] + arr[j] * arr[k]) is 97.

3) (7, 8, 10), and value of (arr[i] + arr[j] * arr[k]) is 87.

4) (7, 8, 11), and value of (arr[i] + arr[j] * arr[k]) is 105.

5) (3, 8, 10), and value of (arr[i] + arr[j] * arr[k]) is 83.

6) (3, 8, 11), and value of (arr[i] + arr[j] * arr[k]) is 91.

Therefore, the maximum among the values is 106

Input:_ arr[]={1, 2, 3}_

Output:_ 7_

#arrays #mathematical #java-treeset

Hertha  Mayer

Hertha Mayer

1594769515

How to validate mobile phone number in laravel with example

Data validation and sanitization is a very important thing from security point of view for a web application. We can not rely on user’s input. In this article i will let you know how to validate mobile phone number in laravel with some examples.

if we take some user’s information in our application, so usually we take phone number too. And if validation on the mobile number field is not done, a user can put anything in the mobile number field and without genuine phone number, this data would be useless.

Since we know that mobile number can not be an alpha numeric or any alphabates aand also it should be 10 digit number. So here in this examples we will add 10 digit number validation in laravel application.

We will aalso see the uses of regex in the validation of mobile number. So let’s do it with two different way in two examples.

Example 1:

In this first example we will write phone number validation in HomeController where we will processs user’s data.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;

class HomeController extends Controller
{
    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('createUser');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $request->validate([
                'name' => 'required',
                'phone' => 'required|digits:10',
                'email' => 'required|email|unique:users'
            ]);

        $input = $request->all();
        $user = User::create($input);

        return back()->with('success', 'User created successfully.');
    }
}

Example 2:

In this second example, we will use regex for user’s mobile phone number validation before storing user data in our database. Here, we will write the validation in Homecontroller like below.

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use App\User;
use Validator;

class HomeController extends Controller
{
    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        return view('createUser');
    }

    /**
     * Show the application dashboard.
     *
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        $request->validate([
                'name' => 'required',
                'phone' => 'required|regex:/^([0-9\s\-\+\(\)]*)$/|min:10',
                'email' => 'required|email|unique:users'
            ]);

        $input = $request->all();
        $user = User::create($input);

        return back()->with('success', 'User created successfully.');
    }
}

#laravel #laravel phone number validation #laravel phone validation #laravel validation example #mobile phone validation in laravel #phone validation with regex #validate mobile in laravel

How To Validate 10 Digit Mobile Number Using Regular Expression

In This small tutorial i will expain you how to validate 10 digit mobile number using regular expression in laravel or php.

The Regex validatation gives flexibility to user to enter numbers in different format as per user’s requirments.When you are working with form validation at that time You need to restrict user to enter invalid value and users allow only numeric value and enter 10 digits number specially for indian mobile no validation.

So let’s start…

You need to copy below code in your view or html file to get output.

Read More : https://websolutionstuff.com/post/how-to-validate-10-digit-mobile-number-using-regular-expression


Read Also : Laravel AJAX CRUD example

#validate #mobile #number #regex #validation #regular expression

Gerhard  Brink

Gerhard Brink

1622622360

Data Validation in Excel

Data Validation in Excel

In this tutorial, let’s discuss what data validation is and how it can be implemented in MS-Excel. Let’s start!!!

What Is Data Validation in Excel?

Data Validation is one of the features in MS-Excel which helps in maintaining the consistency of the data in the spreadsheet. It controls the type of data that can enter in the data validated cells.

Data Validation in MS Excel

Now, let’s have a look at how data validation works and how to implement it in the worksheet:

To apply data validation for the cells, then follow the steps.

1: Choose to which all cells the validation of data should work.

2: Click on the DATA tab.

3: Go to the Data Validation option.

4: Choose the drop down option in it and click on the Data Validation.

data validation in Excel

Once you click on the data validation menu from the ribbon, a box appears with the list of data validation criteria, Input message and error message.

Let’s first understand, what is an input message and error message?

Once, the user clicks the cell, the input message appears in a small box near the cell.

If the user violates the condition of that particular cell, then the error message pops up in a box in the spreadsheet.

The advantage of both the messages is that the input and as well as the error message guide the user about how to fill the cells. Both the messages are customizable also.

Let us have a look at how to set it up and how it works with a sample

#ms excel tutorials #circle invalid data in excel #clear validation circles in excel #custom data validation in excel #data validation in excel #limitation in data validation in excel #setting up error message in excel #setting up input message in excel #troubleshooting formulas in excel #validate data in excel

I am Developer

1597565398

Laravel 7/6 Image Validation

In this image validation in laravel 7/6, i will share with you how validate image and image file mime type like like jpeg, png, bmp, gif, svg, or webp before uploading image into database and server folder in laravel app.

https://www.tutsmake.com/image-validation-in-laravel/

#laravel image validation #image validation in laravel 7 #laravel image size validation #laravel image upload #laravel image validation max #laravel 6 image validation