iamdestinychild / 30-days-dsa-challenge Goto Github PK
View Code? Open in Web Editor NEWA 30 days challange for you to learn data structure and algorithm
License: MIT License
A 30 days challange for you to learn data structure and algorithm
License: MIT License
Given the root of a binary tree, return the inorder traversal of its nodes' values.
This Problem is related to Binary Tree data structure
This is a leetcode problem.
Problem:
You are given an integer array nums where the largest integer is unique.
Determine whether the largest element in the array is at least twice as much as every other number in the array. If it is, return the index of the largest element, or return -1 otherwise.
Solved using Java.
Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.
Notice that the solution set must not contain duplicate triplets.
Example 1:
Input: nums = [-1,0,1,2,-1,-4]
Output: [[-1,-1,2],[-1,0,1]]
Explanation:
nums[0] + nums[1] + nums[2] = (-1) + 0 + 1 = 0.
nums[1] + nums[2] + nums[4] = 0 + 1 + (-1) = 0.
nums[0] + nums[3] + nums[4] = (-1) + 2 + (-1) = 0.
The distinct triplets are [-1,0,1] and [-1,-1,2].
Notice that the order of the output and the order of the triplets does not matter.
Link: 3Sum
given the root node return the inorder traversal of it using recursion.
The issue is to solve the problem of finding inorder traversal of binary tree in c++.
Hii @iamdestinychild can i work on it?
You are given the heads of two sorted linked lists list1 and list2.
Merge the two lists into one sorted list. The list should be made by splicing together the nodes of the first two lists.
Return the head of the merged linked list.
Example 1:
Input: list1 = [1,2,4], list2 = [1,3,4]
Output: [1,1,2,3,4,4]
Link: Merge Two Sorted Lists
Description
This issue requests the addition of a solution for the 48.Rotate Image problem
This is a leetcode problem. I wish to contribute this problem in your repo. so assign this issue under hacktoberfest label.
Monotonic Array Problem
Given the head of a sorted linked list, delete all duplicates such that each element appears only once. Return the linked list sorted as well.
Example 1:
Input: head = [1,1,2]
Output: [1,2]
DESCRIPTION
Given a string expression of numbers and operators, return all possible results from computing all the different possible ways to group numbers and operators. You may return the answer in any order.
The test cases are generated such that the output values fit in a 32-bit integer and the number of different results does not exceed 104.
Example 1:
Input: expression = "2-1-1"
Output: [0,2]
Explanation:
((2-1)-1) = 0
(2-(1-1)) = 2
This is the Leetcode problem.
DSA PROBLEM -
https://leetcode.com/problems/different-ways-to-add-parentheses/
Can you assign this to me?
This is a medium level difficulty problem on leetcode, know for being asked in interviews by big tech organizations
Finding first and last position of an element in a sorted array
This is a leetcode problem
Given an integer array nums and an integer k, split nums into k non-empty subarrays such that the largest sum of any subarray is minimized.
Return the minimized largest sum of the split.
A subarray is a contiguous part of the array.
Approach: Solved using binary search
Assign this issue to me.
The problem asks for two indices in an array of integers such that the elements at these indices add up to a given target value. The initial thought is to use a hash table (unordered_map in C++) to keep track of elements and their indices while iterating through the array. This approach allows us to efficiently check if a complement (the value needed to reach the target) exists in the array.
Given an array of integers nums and an integer target, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
You can return the answer in any order.
Example 1:
Input: nums = [2,7,11,15], target = 9
Output: [0,1]
Explanation: Because nums[0] + nums[1] == 9, we return [0, 1].
Given a string s, find the length of the longest substring without repeating characters.
https://leetcode.com/problems/longest-substring-without-repeating-characters/
You are given an array of integers nums, there is a sliding window of size k which is moving from the very left of the array to the very right. You can only see the k numbers in the window. Each time the sliding window moves right by one position.
Return the max sliding window.
You are given two integers, num and t.
An integer x is called achievable if it can become equal to num after applying the following operation no more than t times:
Increase or decrease x by 1, and simultaneously increase or decrease num by 1.
Return the maximum possible achievable number. It can be proven that there exists at least one achievable number.
Above mentioned problem is related to mathematical computation algorithm
You are given an array of strings tokens that represents an arithmetic expression in a Reverse Polish Notation.
Evaluate the expression. Return an integer that represents the value of the expression.
Note that:
https://leetcode.com/problems/evaluate-reverse-polish-notation/description/
Given an array of integers nums, return the number of good pairs.
A pair (i, j) is called good if nums[i] == nums[j] and i < j.
Example 1:
Input: nums = [1,2,3,1,1,3]
Output: 4
Explanation: There are 4 good pairs (0,3), (0,4), (3,4), (2,5) 0-indexed.
Example 2:
Input: nums = [1,1,1,1]
Output: 6
Explanation: Each pair in the array are good.
Example 3:
Input: nums = [1,2,3]
Output: 0
Constraints:
1 <= nums.length <= 100
1 <= nums[i] <= 100
I WANT TO CONTRIBUTE THE SOLUTION OF THIS ABOVE MENTIONED QUESTION SO PLEASE ASSIGN ME THIS WITH HACKTOBERFEST TAG ON IT.
Leetcode Problems
Given a binary tree root, return the maximum sum of all keys of any sub-tree which is also a Binary Search Tree (BST).
Assume a BST is defined as follows:
Language Used - Python3
This is a Leetcode question
Given an integer array nums, return an array answer such that answer[i] is equal to the product of all the elements of nums except nums[i].
The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.
You must write an algorithm that runs in O(n) time and without using the division operation.
Example 1:
Input: nums = [1,2,3,4]
Output: [24,12,8,6]
Example 2:
Input: nums = [-1,1,0,-3,3]
Output: [0,0,9,0,0]
Constraints:
2 <= nums.length <= 105
-30 <= nums[i] <= 30
The product of any prefix or suffix of nums is guaranteed to fit in a 32-bit integer.
Follow up: Can you solve the problem in O(1) extra space complexity? (The output array does not count as extra space for space complexity analysis.)
The problem requires finding the index at which a target value should be inserted into a sorted array of distinct integers while maintaining the sorted order. If the target is already in the array, we return its index. the thought is to use a binary search algorithm to efficiently find the insertion point.
The problem will be solved in C++ programming language.
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.
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
This is a leetcode problem.
Problem Description:
Given a non-negative integer x, return the square root of x rounded down to the nearest integer. The returned integer should be non-negative as well.
Solved using binary search approach
The problem requires us to find topological sort to see if we can take all the courses or not because we need to take one course to take another one.
Course Schedule 2
Given an integer array nums of length n, you want to create an array ans of length 2n where ans[i] == nums[i] and ans[i + n] == nums[i] for 0 <= i < n (0-indexed).
Specifically, ans is the concatenation of two nums arrays.
Return the array ans.
Example 1:
Input: nums = [1,2,1]
Output: [1,2,1,1,2,1]
Explanation: The array ans is formed as follows:
Input: nums = [1,3,2,1]
Output: [1,3,2,1,1,3,2,1]
Explanation: The array ans is formed as follows:
Constraints:
n == nums.length
1 <= n <= 1000
1 <= nums[i] <= 1000
Given an m x n
binary matrix mat
, return the distance of the nearest 0 for each cell.
The distance between two adjacent cells is 1
.
Input: mat = [[0,0,0],[0,1,0],[0,0,0]]
Output: [[0,0,0],[0,1,0],[0,0,0]]
Input: mat = [[0,0,0],[0,1,0],[1,1,1]]
Output: [[0,0,0],[0,1,0],[1,2,1]]
You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.
Merge all the linked-lists into one sorted linked-list and return it.
Merge k Sorted Lists
Description
Implement Strictly Palindromic Number
An integer n is strictly palindromic if, for every base b between 2 and n - 2 (inclusive), the string representation of the integer n in base b is palindromic.
I am adding more context to the contribution.md file to make things clear for the contributors
Contribution.md file out of context
No response
The twoSum() method takes two arguments: the input array (nums) and the target sum (target).
For each element (num) in the input array, the method calculates the complement (complement) of that element._
The method checks if the complement is already in the hash table (container). If it is, then the method returns the indices of the two elements (container[complement] and i).
Otherwise, the method adds the element to the hash table (container[num] = i).
class Solution(object):
def twoSum(self, nums, target):
Given an array of integers nums
and an integer target
, return indices of the two numbers such that they add up to target.
You may assume that each input would have exactly one solution, and you may not use the same element twice.
You can return the answer in any order.
Description
This issue requests the addition of the solution for the 71. Simplify Path problem
You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.
Merge all the linked-lists into one sorted linked-list and return it.
https://leetcode.com/explore/interview/card/top-interview-questions-hard/117/linked-list/839/
Problem link:-https://leetcode.com/problems/merge-k-sorted-lists/
You are given an array of k linked-lists lists, each linked-list is sorted in ascending order.
Merge all the linked-lists into one sorted linked-list and return it.
I
[23. Merge k Sorted Lists]
GitHub Actions is a versatile tool that can be used to automate a wide range of tasks. It is a powerful tool that can help you to improve the efficiency and quality of your codes.
Leetcode problems
Given an integer array height of length n. There are n vertical lines drawn such that the two endpoints of the ith line are (i, 0) and (i, height[i]).
Find two lines that together with the x-axis form a container, such that the container contains the most water.
Return the maximum amount of water a container can store.
Notice that you may not slant the container.
Language Used - Python3
Program to solve sudoku puzzle by filling the empty cells
A sudoku solution must satisfy all of the following rules:
You are given an integer array nums and two integers indexDiff and valueDiff.
Find a pair of indices (i, j) such that:
i != j,
abs(i - j) <= indexDiff.
abs(nums[i] - nums[j]) <= valueDiff, and
Return true if such pair exists or false otherwise.
Find Duplicate Pair with Conditions
An update to the GitHub workflow
auto-assign
This is a hard level difficulty problem on leetcode
Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining
A peak element is an element that is strictly greater than its neighbors.
Given a 0-indexed integer array nums, find a peak element, and return its index. If the array contains multiple peaks, return the index to any of the peaks.
You may imagine that nums[-1] = nums[n] = -∞. In other words, an element is always considered to be strictly greater than a neighbor that is outside the array.
Peak Element in Array
basic introductory solution to if statement task in python
this is the problem that will help to understand the concept of the backtracking.
The N-Queens puzzle is a classic problem in computer science and mathematics. In this puzzle, the goal is to place N chess queens on an N×N chessboard in such a way that no two queens threaten each other.
This issue requests the addition of the solution for the trapping rain water problem
Given a rows x cols binary matrix filled with 0's and 1's, find the largest rectangle containing only 1's and return its area.
https://leetcode.com/problems/maximal-rectangle/description/
Given an integer array nums and an integer k, split nums into k non-empty subarrays such that the largest sum of any subarray is minimized.
Return the minimized largest sum of the split.
A subarray is a contiguous part of the array.
https://leetcode.com/problems/split-array-largest-sum/description/
The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility)
P A H N
A P L S I I G
Y I R
And then read line by line: "PAHNAPLSIIGYIR"
Write the code that will take a string and make this conversion given a number of rows:
string convert(string s, int numRows);
Example 1:
Input: s = "PAYPALISHIRING", numRows = 3
Output: "PAHNAPLSIIGYIR"
Link: Zigzag Conversion
Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where:
'.' Matches any single character.
'*' Matches zero or more of the preceding element.
The matching should cover the entire input string (not partial).
Example 1:
Input: s = "aa", p = "a"
Output: false
Explanation: "a" does not match the entire string "aa".
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.