Leetcode with dani
1.29K subscribers
202 photos
14 videos
56 files
243 links
Join us and let's tackle leet code questions together: improve your problem-solving skills
Preparing for coding interviews
learning new algorithms and data structures
connect with other coding enthusiasts
Download Telegram
#leet_code_Q1 #Array Given a non-empty array of integers nums, every element appears twice except for one. Find that single one.

You must implement a solution with a linear runtime complexity and use only constant extra space.



Example 1:

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

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

Input: nums = [1]
Output: 1 Each element in the array appears twice except for one element which appears only once.
πŸ‘4
#leet_code_Q2 #Array #leet_code_169 #Majority_Element Given an array nums of size n, return the majority element.

The majority element is the element that appears more than (n / 2)times. You may assume that the majority element always exists in the array.

Example 1:

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

Input: nums = [2,2,1,1,1,2,2]
Output: 2
Day 5
πŸ—“ Daily Challenge #1
🧩 Build Array from Permutation
Given an array nums, build a new array ans where ans[i] = nums[nums[i]] for every index i.
Can you solve it without extra space? (Hint: Think modulo!)

πŸ”— Problem Link:
πŸ“Œ Difficulty: Easy
🏷 Tags: #Array #InPlace

πŸ’‘ Let’s see your optimized solutions!
πŸ‘‰ Drop your approach in the comments!

πŸ“Š Problem Breakdown #2
πŸ”„ Matrix Rotation Check
Given two n x n matrices, determine if one can be obtained by rotating the other 90Β°, 180Β°, or 270Β°.
How would you efficiently check all possible rotations?

πŸ”— Problem Link:
πŸ“Œ Difficulty: Medium
🏷 Tags: #Matrix #Transpose

πŸ€” Think about transpose + reverse vs. brute force. Which is better?
πŸ‘‰ Share your code snippets!

πŸš€ Advanced Problem Alert!
πŸ”’ Tuple with Same Product
Find the number of tuples (a, b, c, d) such that a*b = c*d where all elements are distinct.
Can you avoid an O(n⁴) solution? (Hint: Hash maps are your friend!)

πŸ”— Problem Link:
πŸ“Œ Difficulty: Medium
🏷 Tags: #HashTable #Combinatorics

πŸ’₯ Challenge: Optimize for large arrays!
πŸ‘‰ Post your best time complexity in the comments!
πŸ‘3