With the increasing seniority in software development, comes up with multiple tasks to manage. I used to struggle between different meetings, completing my tasks, addressing the team’s issues and ad hoc productions bugs. Time used to fly like anything with very less productivity.
Some startups I worked with, did not have a proper tool for bug tracking. They used to create tasks in Google Document or assign bugs on Slack. This created a lot of chaos with no visibility on my work progress. End of the day I did not get the satisfaction of the work being done. …
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
Problem statement taken from: https://leetcode.com/problems/maximum-subarray
Input: nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4]
Explanation: [4, -1, 2, 1] has the largest sum = 6.
Input: nums = 
Input: nums = [5, 4, -1, 7, 8]
- 1 <= nums.length <= 3 * 10^4 -
-10^5 <= nums[i] <= 10^5
The brute force approach is to generate all subarrays and…
Given an array of integers nums sorted in ascending order, find the starting and ending position of a given target value.
If target is not found in the array, return [-1, -1].
Problem statement taken from: https://leetcode.com/problems/find-first-and-last-position-of-element-in-sorted-array
Input: nums = [5, 7, 7, 8, 8, 10], target = 8
Output: [3, 4]
Input: nums = [5, 7, 7, 8, 8, 10], target = 6
Output: [-1, -1]
Input: nums = , target = 0
Output: [-1, -1]
- 0 <= nums.length <= 10^5
- -10^9 <= nums[i] <= 10^9
- nums is a non-decreasing array.
Given a sorted array nums, remove the duplicates in-place such that each element appears only once and returns the new length.
Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory.
Problem statement taken from: https://leetcode.com/problems/remove-duplicates-from-sorted-array
Input: nums = [1, 1, 2]
Output: 2, nums = [1, 2]
Explanation: Your function should return length = 2, with the first two elements of nums being 1 and 2 respectively. It doesn't matter what you leave beyond the returned length.
Input: nums = [0, 0, 1…
Given a non-negative integer x, compute and return the square root of x.
Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned.
Note: You are not allowed to use any built-in exponent function or operator, such as
pow(x, 0.5) or
x ** 0.5.
Problem statement taken from: https://leetcode.com/problems/sqrtx
Input: x = 4
Input: x = 8
Explanation: The square root of 8 is 2.82842..., and since the decimal part is truncated, 2 is returned.
0 <= x <=…
Given the head of a linked list, remove the nth node from the end of the list and return its head.
Input: head = [1,2,3,4,5], n = 2
Input: head = , n = 1
Input: head = [1,2], n = 1
- The number of nodes in the list is sz.
- 1 <= sz <= 30
- 0 <= Node.val <= 100
- 1 <= n <= sz
One of the approaches to solve this problem is use single pointer by following the below steps
Roman numerals are represented by seven different symbols: I, V, X, L, C, D and M.
For example, 2 is written as II in Roman numeral, just two one’s added together. 12 is written as XII, which is simply X + II. The number 27 is written as XXVII, which is XX + V + II.
Roman numerals are usually written largest to smallest from left to right. However, the numeral for four is not IIII. Instead, the number four is written as IV…
Given N non-negative integers a1, a2, …, an, where each represents a point at coordinate(i, ai). N vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water.
Problem statement taken from: https://leetcode.com/problems/container-with-most-water
Input: height = [1, 8, 6, 2, 5, 4, 8, 3, 7]
Input: height = [1, 1]
Input: height = [4, 3, 2, 1, 4]
Given an integer x, return true if x is palindrome integer.
An integer is a palindrome when it reads the same backward as forward. For example, 121 is palindrome while 123 is not.
Input: x = 121
Input: x = -121
Input: x = 10
Input: x = -101
- -2^31 <= x <= 2^31 - 1
As mentioned in the problem statement, palindrome number is one that reads the same from both sides.
A brute force solution will be to convert the…
Implement the myAtoi(string s) function, which converts a string to a 32-bit signed integer (similar to C/C++’s atoi function).
Problem statement taken from: https://leetcode.com/problems/string-to-integer-atoi
Input: s = "42"
Input: s = " -142"
Input: s = "871 and words"
Input: s = "Words and then number 987"
Input: s = "-91283472332"
- 0 <= s.length <= 200
- s consists of English letters (lower-case and upper-case), digits (0-9), ' ', '+', '-', and '.'