Introduction🛹

Hey guys, Today is day 27 of the 100 Days to** LinkedIn Challenge.**

Image for post

Free For Kindle Readers

If you are Preparing for your Interview. Even if you are settled down in your job, keeping yourself up-to-date with the latest **Interview Problems **is essential for your career growth. Start your **prep **from Here!

Last month, I have been researching to find out the Frequently asked problems from these Companies. I have compiled **100 **of these questions, I am not promising you that you will get these questions in your interview but I am confident that most of these “interview questions” have similar logic and employs the same way of thinking from these set of challenges.

Before we move on to the problem, If you are wondering why I chose LinkedIn, Yahoo and Oracle over FAANG are because I have completed a challenge Focusing on Amazon and Facebook Interview.

New Day, New Strength, New Thoughts🚀

Day 27 — Increasing Triplet Sequence🏁

AIM🏹

Given an unsorted array return whether an increasing subsequence of length 3 exists or not in the array.

Formally the function should:

Return true if there exists i, j, k
such that arr[i] < arr[j] < arr[k] given 0 ≤ i < j < k ≤ n-1 else return false.

**Note: **Your algorithm should run in O(n) time complexity and O(1) space complexity.

Example🕶

Input: [1,2,3,4,5]
Output: true

Input: [5,4,3,2,1]
Output: false

FollowHouse of Codes_ for keeping up to date in the programming interview world._

Code👇

	class Solution {
	    public boolean increasingTriplet(int[] nums) {
	        if(nums.length<3)
	            return false;
	        int first = Integer.MAX_VALUE;
	        int second = Integer.MAX_VALUE;
	        int third = Integer.MAX_VALUE;
	        for(int i=0;i<nums.length;i++)
	        {
	            if(nums[i]<= first)
	                first = nums[i];
	            else if(nums[i]<= second)
	                second = nums[i]; 
	            else if(nums[i]<= third)
	                third = nums[i];
	            if(first < Integer.MAX_VALUE && second < Integer.MAX_VALUE && third < Integer.MAX_VALUE)
	                return true;
	        }
	            return false;
	    }
	}

#programming #software-development #interview #java #coding

How to Solve Increasing triplet Sequence?
2.55 GEEK