Leetcode-Top -150-Interview-Question -Day -2: Array && String

Shubham Saha
Feb 7, 2024

--

Question 1:169. Majority Element

Problem Statement:

In this question we are given an array nums of size n. We need to return the majority Element.

Majority Element : The majority element is the element that appears more than N/2 times.

CODE:

Complexity :

Time complexity: O(n);

Space Complexity: O(1);

QUESTION 2 : 383. Ransom Note

Problem Statement:

In this question we are given two strings (ransomNote) and (magazine) . We just need to return boolean if (ransomNote ) string is contructed by using letters of (magazine).

CODE :

Complexity :

Time complexity: O(n);

Space Complexity: O(26) ~O(1);

HOPE YOU LIKE MY APPROACHES!!!

THANKYOU!!!

--

--

Shubham Saha
Shubham Saha

Written by Shubham Saha

Full Stack Developer | Expert in React, Node.js, Express.js, MongoDB, MySQL | Proficient in Data Structures and Algorithms | Exploring Next.js

No responses yet