Mohit Profile picture
21 | SWE @PTC | 2023 Graduate | I tweet about my learnings/Readings/Experience.
Jun 21, 2022 8 tweets 2 min read
Day 4 of #100DaysOfCode :

Problem Name - Longest Consecutive Sequence

Given an unsorted array of integers "nums", return the length of the longest consecutive elements sequence.

🧵👇 Sample Input :

arr = [100,4,200,1,3,2]

Sample Output:

4

Explanation:

The longest consecutive elements sequence is [1, 2, 3, 4].

Therefore its length is 4.
Jun 20, 2022 6 tweets 2 min read
Day 3 of #100DaysOfCode :
Problem Name - Longest Mountain in Array

Given an integer array "arr", return the length of the longest subarray, which is a mountain.

🧵👇 Sample Input :

arr = [2,1,4,7,3,2,5]

Sample Output:

5

Explanation:

A mountain is a set of numbers that are strictly increasing until they reach a peak, at which they become strictly decreasing.

So, the largest mountain is [1,4,7,3,2] with peak at 7 and length 5.
Jun 19, 2022 7 tweets 2 min read
Day 2 of #100DaysOfCode

PROBLEM NAME - 3 SUM

Given an array of integers "nums" and an integer "target", find all possible indices of triplets such that they add up to target.

A thread 🧵👇 Approach - 1 : Brute Force

Use 3 "for loops" and check for all possible triplets of numbers that makes the target sum.

Time Complexity - O(n^3)
Space Complexity - O(1) Image
Jun 18, 2022 8 tweets 3 min read
Day 1 of #100DaysOfCode :
Problem Name - TWO SUM

Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.

A thread 🧵👇 Approach - 1 : Brute Force

- Use 2 for loops and check for all possible pairs of numbers that makes the target sum.

Time Complexity - O(n^2)
Space Complexity - O(1) Image