Posts

Leetcode - Valid Mountain Array

Image
Given an array  A  of integers, return  true  if and only if it is a  valid mountain array . Recall that A is a mountain array if and only if: A.length >= 3 There exists some  i  with  0 < i < A.length - 1  such that: A[0] < A[1] < ... A[i-1] < A[i] A[i] > A[i+1] > ... > A[A.length - 1] Example 1: Input: [2,1] Output: false Example 2: Input: [3,5,5] Output: false Example 3: Input: [0,3,2,1] Output: true Note: 0 <= A.length <= 10000 0 <= A[i] <= 10000  Link : https://leetcode.com/problems/valid-mountain-array/  Solution : class Solution { public boolean validMountainArray ( int [] A ) { int i = 0 ; while ( i < A . length && i + 1 < A . length && A [ i ]< A [ i + 1 ]){ i ++; } if ( i == 0 || i + 1 >= A . length ){ ...

LeetCode – 4Sum (Java)

Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target. Note: Elements in a quadruplet (a,b,c,d) must be in non-descending order. (ie, a ≤ b ≤ c ≤ d) The solution set must not contain duplicate quadruplets. For example, given array S = {1 0 -1 0 -2 2}, and target = 0. A solution set is: (-1, 0, 0, 1) (-2, -1, 1, 2) (-2, 0, 0, 2) Java Solution A typical k-sum problem. Time is N to the power of (k-1). public List < List < Integer >> fourSum ( int [ ] nums, int target ) { List < List < Integer >> result = new ArrayList < List < Integer >> ( ) ;   if ( nums == null || nums. length < 4 ) return result ;   Arrays . sort ( nums ) ;   for ( int i = 0 ; i < nums. length - 3 ; i ++ ) { if ( i != 0 && nums [ i ] == nums [ i - 1 ...

Why i choosen Mobile Technology

Image
When I was in School the Computer Market boom!! Everyone want to buy Computer. When I enter the Engineer the Mobile Market BOOOMM!! and it downgrade the Computer. But After Mobile market no one has downgraded it. It has upgraded and moving. Day-by-Day Mobile becoming smarter and Faster, giving all the power of Computer stuff in Mobile. From that onward Mobile Market has grown 5 Times the Computer market and that was what change my Mind from developing Softwares for PC to Mobile Developer. Where there are Only 2 Major Mobile Operating System. iOS Android Why i choosen Android? I choosen Android because, it is open-source, it is Operated by "Google" and it Hold the Major shares in Market. iOS if for Rich its operating cost (99$ per year, And Require Mac) is high and I will need lot to Compete with big Company on iTunes Store. Where on Android Cost is too low (25$ lifetime) and Open Source. So I gone with Quantity 2.3 Billion Devices, to share your IDEA. Check ...