Category: fullstackdevelopment

  • How to run AWS Serverless in local?

    AWS Lambda is a serverless application. That means you don’t have control over where to deploy your app on AWS. AWS will take care of that. But where and how do you deploy the app locally for your testing. You can do this in two ways: Using Serverless invoke local command: Using this command you…

  • How to set up serverless framework?

    Serverless applications brought about a new paradigm in programming. You no longer need to worry about server infrastructure and concentrate only on your business logic. AWS lambda serves this purpose. And Serverless is a framework that eases the development and deployment of AWS lambdas. Here is how to set up the serverless framework in your…

  • Median of Two Sorted Arrays

    Problem : Given two sorted arrays find the median of the sorted arrays when merged. Find a solution in less than O(n) time complexity where n is the length of the merged array. Also don’t use extra space – Space complexity should be O(1) What is median? Median is the middlemost element of a sorted…

  • Find first and last position of element in sorted array

    Problem: Given a sorted integer array find the first and last position of given target element For example, If given array is [ 1,3,6,6,7,9] and target is 6 Then output is [2,3] which represents the first and last index position of the element 6 For the same input if the target is 8 Then the…

  • Rotate Array

    Problem: Given an integer array and a number k , rotate the array by k positions to the right. For example, If the given array is [1,2,3,4,5,6,7,8] and k = 4 Then the output is [5,6,7,8,1,2,3,4] Pushing an element out of the array makes it land in the beginning of the array. Try out the…

  • Find Peak element in an array

    Problem: Given an integer array return the index of any peak element in it. Find a solution in O(logn) time. A peak element is an element which is greater than its neighbors. Its neighbors are the immediate elements to its left and right. you can return any peak element. So for example , if the…

  • Find first missing positive integer in an array.

    Problem: Given an array of integers find the first missing positive integer . The first positive integer is 1. So if 1 is itself missing you need to return 1 else whatever number after 1 is missing that should be returned. For example, Given the array: [1,2,4,5] The output is 3 Given the array: [3,4,-1,1,5]…

  • Kth largest element in an array

    Given an array of integers, find the kth largest element in the array. For example, Given the input [3,2,1,5,6,4] and k = 2 The output is 5 Try out the solution here: https://leetcode.com/problems/kth-largest-element-in-an-array/ Solution: We can solve this problem in multiple ways. Let’s look at three approaches. Approach 1 – Sort the array In this…

  • Find the element which appears more than half the array size

    Given an array, find the majority element which appears more than half the size of the array. Constraints: For example, in the below array: [7,6,8,7,7,7] The output is 7 since it appears 4 times which is more than half the size of the array (3) Solution: Finding a solution with O(n) extra space is easier.…

  • Single non duplicate number in an array

    Given an array with all elements repeated twice except one element find out that element. Constraints: The time complexity should be O(n) Space complexity should be O(1) For example: Given the array : [1,3,4,3,4] the output is 1 since it occurs only once. Try out the solution here: https://leetcode.com/problems/single-number Solution: If we can use extra…