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. …


Problem statement

Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list’s nodes (i.e., only nodes themselves may be changed.)

Problem statement taken from: https://leetcode.com/problems/swap-nodes-in-pairs

Example 1:

Input: head = [1, 2, 3, 4] 
Output: [2, 1, 4, 3]

Example 2:

Input: head = []
Output: []

Example 3:

Input: head = [1]
Output: [1]

Constraints:

- The number of nodes in the list is in the range [0, 100]. 
- 0 <= Node.val <= 100

Explanation

Swapping links

Since the node values cannot be swapped, changing links is a…


Problem statement

Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.

If such an arrangement is not possible, it must rearrange it as the lowest possible order (i.e., sorted in ascending order).

The replacement must be in place and use only constant extra memory.

Problem statement taken from: https://leetcode.com/problems/next-permutation

Example 1:

Input: nums = [1, 2, 3]
Output: [1, 3, 2]

Example 2:

Input: nums = [3, 2, 1]
Output: [1, 2, 3]

Example 3:

Input: nums = [1, 1, 5]
Output: [1, 5, 1]

Example 4:

Input: nums = [1]
Output: [1]

Constraints:

- 1 <=…


Problem statement

Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.

You must write an algorithm with O(log n) runtime complexity.

Problem statement taken from: https://leetcode.com/problems/search-insert-position

Example 1:

Input: nums = [1, 3, 5, 6], target = 5
Output: 2

Example 2:

Input: nums = [1, 3, 5, 6], target = 2
Output: 1

Example 3:

Input: nums = [1, 3, 5, 6], target = 7
Output: 4

Example 4:

Input: nums = [1, 3, 5, 6]…

Problem statement

Merge two sorted linked lists and return it as a sorted list. The list should be made by splicing together the nodes of the first two lists.

Problem statement taken from: https://leetcode.com/problems/merge-two-sorted-lists

Example 1:

Input: l1 = [1, 2, 4], l2 = [1, 3, 4]
Output: [1, 1, 2, 3, 4, 4]

Example 2:

Input: l1 = [], l2 = []
Output: []

Example 3:

Input: l1 = [], l2 = [0]
Output: [0]

Constraints:

- The number of nodes in both lists is in the range [0, 50].
- -100 <= Node.val …


Problem statement

Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays.

The overall run time complexity should be O(log (m+n)).

Problem statement taken from: https://leetcode.com/problems/median-of-two-sorted-arrays

Example 1:

Input: nums1 = [1, 3], nums2 = [2]
Output: 2.00000
Explanation: merged array = [1, 2, 3] and median is 2.

Example 2:

Input: nums1 = [1, 2], nums2 = [3, 4]
Output: 2.50000
Explanation: merged array = [1, 2, 3, 4] and median is (2 + 3) / 2 = 2.5.

Example 3:

Input: nums1 = [0, 0], nums2 = [0, 0]
Output…


Problem statement

Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.

Problem statement taken from: https://leetcode.com/problems/generate-parentheses

Example 1:

Input: n = 3
Output: ["((()))", "(()())", "(())()", "()(())", "()()()"]

Example 2:

Input: n = 1
Output: ["()"]

Constraints:

- 1 <= n <= 8

Explanation

Brute force

A brute force approach to this problem is to generate all combinations of parenthesis using ( and ). Then verify which are the valid ones and add the valid ones to the result.

A small C++ code snippet of the above logic will look as below:

vector<string> generateParenthesis(int n) {…


Problem statement

Given a string containing digits from 2–9 inclusive, return all possible letter combinations that the number could represent. Return the answer in any order.

A mapping of digit to letters (just like on the telephone buttons) is given below. Note that 1 does not map to any letters.

Problem statement taken from: https://leetcode.com/problems/letter-combinations-of-a-phone-number

Example 1:

Input: digits = "23"
Output: ["ad", "ae", "af", "bd", "be", "bf", "cd", "ce", "cf"]

Example 2:

Input: digits = ""
Output: []

Example 3:

Input: digits = "2"
Output: ["a", "b", "c"]

Constraints:

- 0 <= digits.length <= 4
- digits[i] is a digit in the…


Problem statement

Given a non-empty array of decimal digits representing a non-negative integer, increment one to the integer.

The digits are stored such that the most significant digit is at the head of the list, and each element in the array contains a single digit.

You may assume the integer does not contain any leading zero, except the number 0 itself.

Problem statement taken from: https://leetcode.com/problems/plus-one

Example 1:

Input: digits = [1, 2, 3]
Output: [1, 2, 4]
Explanation: The array represents the integer 123.

Example 2:

Input: digits = [4, 3, 2, 1]
Output: [4, 3, 2, 2]
Explanation: The array represents the…


Problem statement

Implement strStr().

Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.

Clarification:

What should we return when needle is an empty string? This is a great question to ask during an interview.

For the purpose of this problem, we will return 0 when needle is an empty string. This is consistent to C’s strstr() and Java’s indexOf().

Problem statement taken from: https://leetcode.com/problems/implement-strstr

Example 1:

Input: haystack = "hello", needle = "ll"
Output: 2

Example 2:

Input: haystack = "aaaaa", needle = "bba"
Output: -1

Example 3:

Input: haystack =…

Alkesh Ghorpade

Software Engineer. Working Saeloun. My portfolio https://alkeshghorpade.me

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store