leetcode


Solution 1: The Brute Force Approach Straight away, what we can do is to add 2 elements of the array and compare the result with the target. In order to perform the addition, we need to add one element of the array with every other element in the array to cover all the possibilities.



LeetCode is the de facto and primary educational platform for people preparing for software development and software engineer (SWE) interviews, as well as for people looking to upskill their software development skills in general. According to their site, in two short years after launch, they reached over 1 million users on their platform.



Contribute to 9527tm/lc development by creating an account on GitHub.



694. Number of Distinct Islands Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1 's (representing land) connected 4-directionally (horizontal or vertical.) You may assume all four edges of the grid are surrounded by water. Count the number of distinct islands.



-1 I've got this code that runs in my IDE, Intellij but it will not run in LeetCode. Am I misunderstanding the question? Write a function that reverses a string. The input string is given as an array of characters char []. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O (1) extra memory.



Solution This problem can be solved in following steps :- Create three variables first pointing to index 0, second pointing to last index (n-1, where n is the length of an array) and temp. Copy the character at first variable to temp, the character at second variable to first and character at temp variable to second.



LeetCode ; Introduction Design 348. Design Tic-Tac-Toe. All O`one Data Structure. 252. Meeting Rooms



3 Answers Sorted by: 4 This is a problem with your time complexity. In the leetcode question, it asks for: You must implement a solution with a linear runtime complexity and use only constant extra space. Your answer has time complexity n^2 because of your nested for loops.



1 <= s.length <= 15 s contains only the characters ('I', 'V', 'X', 'L', 'C', 'D', 'M'). It is guaranteed that s is a valid roman numeral in the range [1, 3999]. Idea: ( Jump to: Problem Description || Code: JavaScript | Python | Java | C++)



Dilpreet wants to paint&nbsp;his dog&#39;s home that has&nbsp;n boards with&nbsp;different lengths. The length of ith&nbsp;board is given by arr[i] where arr[] is an array of n integers. He hired k painters for this work and each painter takes 1 unit



Detect Cycle in a Directed Graph using DFS The idea is to traverse the graph along a particular route and check if the vertices of that route form a loop. If the algorithm repeats any vertices twice when traversing along the same route it means that the given graph has a loop (cycle).



Solve one problem based on Data Structures and Algorithms every day and win exciting prizes.