- Notifications
You must be signed in to change notification settings - Fork370
Sudoku solver into a User Interface (UI) application#756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
Ansari-Shamaila wants to merge732 commits intocodemistic:revert-356-patch-1Choose a base branch fromAnsari-Shamaila:main
base:revert-356-patch-1
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes fromall commits
Commits
Show all changes
732 commits Select commitHold shift + click to select a range
b550f7f
Leetcode 23: Merge k sorted linked lists
Aarush2k14bcce70
minFallingPathSumTriangle.cpp created
thisabhijeete4e2dbc
ninjaAndHisFriends.cpp created
thisabhijeet41bf33e
Create COINS - Bytelandian gold coins
AbhishekSrivastava-23c003db5
Merge pull request #599 from thisabhijeet/ninjaAndHisFriends
gantavyamalviya16230cd
Merge pull request #597 from thisabhijeet/minFallingPathSumTriangle
gantavyamalviyad47cc86
Merge pull request #595 from thisabhijeet/maximumNonAdjacentSum
gantavyamalviyafec7629
Merge pull request #594 from thisabhijeet/longestCommonSubstring
gantavyamalviyae35fca6
Create Kruskal's_Algorithm.py
lokesh-797791028cc
CSES solutions
souravkhan121552a58
Merge branch 'codemistic:main' into main
namratabose3297beecd
Sliding Window Median
Aarush2k18958a3b
lowestCommonAncestor.txt added
kokodeshinuf00b11d
minDepth.txt added
kokodeshinu1499771
rightSideView.txt added
kokodeshinud2949d1
sortedArrayToBST.txt added
kokodeshinu42c453c
Create 0-1Knapsack.cpp
jashanwarraich603bee3
Create left view of tree.cpp
ayushkedia0528c24a2
Maximum Sum Circular Subarray Java Solution
Aarush2k1b9880e6
Add : Balanced Brackets and InfixToPostfix program in Java
tiger3768872f479
add: N-Queen Backtrack solution
nilesh05aprfecb695
Added random pass gen and resolved issue #615
sohamdata3f1ba04
Create PolynomialAddition.cpp
Ansh-Kushwahadd842fe
Improve Calculator.py
JYunthd62f68e
Merge branch 'main' of https://github.com/JYunth/Data-Structures-and-…
JYunth33d7b7e
Add files via upload
KBhushan079c11e2a
Add files via upload
KBhushan07b1166b1
Binary Search in 2D Arrays (C++)
Ultimateutkarsh11c61dde1
leetcode soln of remove Nth node from the End
Bluetoothworks4653a73
Implement_Trie
6fee8a1
Delete nodes in a binary tree
SegFault03d6c2b67
Extract all the words from a string
SegFault03fbe023f
added file for operations on arrays in c language
ola-nishant0b8acd6
stack using linked list
divyaa1511c0aabf8
Added Detect a Cycle in a graph
MidhaShreya199d05
Oct 5th : Add one row to tree
vishwajeet-hogale6983635
Create Geek and Strings.cpp
NarpatAanjana83ef52a
Pushkar Roy
ef619bd
added heap sort algo
vaibhav07261246dc7
Added Leetcode Problem 48 Name: Rotate Image(Medium) Url:https://le…
GaurishIIITNR471d67e
Added Leetcode Problem 48
GaurishIIITNR47866eb
Added Leetcode Problem 240
GaurishIIITNRe6328b8
Update 240_Search_a_2D_Matrix_II.cpp
GaurishIIITNR475026a
codeX1616-Code to override Object.equals() method in any java class
codeX16160d3412c
Removing compiled java class files
codeX1616dcb07c6
Added Leetcode Problem 1404
GaurishIIITNR56843f7
Added Leetcode Problem 1404
GaurishIIITNRa52a88b
Create NCRcombination.c
AmanDekate13f3a88f
Added Leetcode String Problem 1404
GaurishIIITNR40a773a
Refactorised Java Folder
arpitghura39f1d20
Added Leetcode String Problem 443
GaurishIIITNR27d51b6
Merge branch 'codemistic:main' into main
PritomKarmokar1b897e1
Added code for Burning tree
jayesh-kumavata22c537
Codeforces 49A in C++
aishalxguptade5e39a
Added code for Implementing Linked List using Java
vaibhav0806f42bc9e
Merge pull request #606 from kokodeshinu/lca
gantavyamalviyafbe060e
Merge pull request #607 from kokodeshinu/minDepth
gantavyamalviya1410aae
Merge pull request #608 from kokodeshinu/rightSideView
gantavyamalviyae8602c5
Merge pull request #609 from kokodeshinu/sortedArrayToBST
gantavyamalviya516287b
Create InsertionInABST.cpp
ShreyasiDebnath82b3b58
Merge pull request #544 from SwagsShivamOp/patch-1
gantavyamalviyab5b0094
Merge pull request #542 from itsokop/patch-2
gantavyamalviya9417d3c
Merge pull request #540 from itsokop/patch-1
gantavyamalviyae8b791b
Merge pull request #543 from itsokop/patch-3
gantavyamalviya6e12d08
Merge pull request #541 from Shubham2816/anagram_part
gantavyamalviyafc09098
Merge pull request #538 from itsokop/main
gantavyamalviya044a979
Merge pull request #536 from Mohammad-Palla/patch-1
gantavyamalviya364ec5e
Merge pull request #534 from DarkSpy25/main
gantavyamalviyad167f0e
Merge pull request #532 from Sudhir8787/patch-2
gantavyamalviyaa6b087f
Merge pull request #529 from Rupesh-Piwal/main
gantavyamalviyabd31dc3
Merge pull request #528 from akshaykhatter/main
gantavyamalviyaefe1211
Merge pull request #525 from PritomKarmokar/main
gantavyamalviya579a04e
Merge pull request #523 from i-see-pixels/patch-4
gantavyamalviya75d9184
Merge pull request #521 from i-see-pixels/patch-2
gantavyamalviyaf243af1
Merge pull request #519 from pranava7/main
gantavyamalviyafad258f
Merge pull request #518 from HarshBhatt123/main
gantavyamalviyaedb8ab4
Merge pull request #537 from JeetuGuptaa/patch-1
gantavyamalviya7a8677f
Merge pull request #535 from durgesh-4526/patch-1
gantavyamalviya6732032
Merge pull request #533 from Dibendu-G/main
gantavyamalviyad8e7286
Merge pull request #531 from Sudhir8787/patch-1
gantavyamalviyaa7116d6
Merge pull request #526 from namratabose32/main
gantavyamalviya929cd42
Merge pull request #524 from priya-19054/main
gantavyamalviya9bb1036
Merge pull request #520 from precisecharmer/main
gantavyamalviya9dbbb12
Merge pull request #522 from i-see-pixels/patch-3
gantavyamalviya8385ce5
Merge pull request #554 from AdityaRaj-ar/main
gantavyamalviyac2e5e94
Merge pull request #575 from Sudhanshu-Purohit/main
gantavyamalviyae130b85
Merge pull request #573 from niharbansal02/main
gantavyamalviyabdc6a35
Merge pull request #569 from Saket109/main
gantavyamalviyad689e01
Merge pull request #567 from YOGENDERSS/main
gantavyamalviya0a43ca8
Merge pull request #566 from varunnitian/main
gantavyamalviya1def548
Merge pull request #564 from ladyinblack/ladyinblack
gantavyamalviyaaaf1975
Merge pull request #563 from kanishka-28/main
gantavyamalviyad349592
Merge pull request #562 from AbhimanyuCODER/patch-2
gantavyamalviya15aa990
Merge pull request #559 from Rituraj-13/symmetric_tree
gantavyamalviyaaedd970
Merge pull request #557 from aniruddho-mitra/patch-1
gantavyamalviya42eef4c
Merge pull request #555 from Pakhi-v/add-hacktoberfest
gantavyamalviyaf1156f3
Merge pull request #550 from Shashank0271/lc1
gantavyamalviya3142239
Merge pull request #549 from aishalg/main
gantavyamalviya104063d
Merge pull request #548 from Yash9460/main
gantavyamalviya0da1b31
Merge pull request #547 from SwagsShivamOp/patch-4
gantavyamalviyaa6babbd
Merge pull request #545 from SwagsShivamOp/patch-2
gantavyamalviyaf73210d
Merge pull request #574 from mas-mis/patch-1
gantavyamalviya9985538
Merge pull request #572 from Sanjanabharadwaj25/TSP
gantavyamalviya9f73b82
Merge pull request #568 from sahanmndl/sahanmndl
gantavyamalviyaae4fc7a
Merge pull request #565 from siddharth3108/TowerofHanoi.java
gantavyamalviya5b8d7bc
Merge pull request #560 from sohanagashimani/main
gantavyamalviyafcbafd7
Merge pull request #558 from KryptonANSHU/Javascript-DSA
gantavyamalviyab7da6d0
Merge pull request #553 from rai-m47/main
gantavyamalviya2afd88f
Merge pull request #546 from SwagsShivamOp/patch-3
gantavyamalviya59104e4
Merge pull request #614 from tiger3768/stjava
gantavyamalviyaf3f0754
Merge pull request #613 from nilesh05apr/nilesh
gantavyamalviya3f9ba9e
Merge pull request #612 from Aarush2k1/patch-3
gantavyamalviya7fbd1e9
Merge pull request #611 from ayushkedia05/main
gantavyamalviyae8c4e2b
Merge pull request #610 from jashanwarraich/patch-3
gantavyamalviyad1503be
Merge pull request #605 from Aarush2k1/patch-2
gantavyamalviyac361e9c
Merge pull request #604 from souravkhan12/main
gantavyamalviyad6e752b
Merge pull request #603 from Lokesh-Choudhary/patch-2
gantavyamalviyac44c3c2
Merge pull request #600 from AbhishekSrivastava-23/patch-1
gantavyamalviyae814ec1
Merge pull request #598 from unfixedbug/main
gantavyamalviya2a603d4
Merge pull request #596 from Aarush2k1/patch-1
gantavyamalviya6d5ba9e
Merge pull request #593 from sanu-020/main
gantavyamalviya0ab2793
Merge pull request #591 from geeky-auro/main
gantavyamalviya84c50fe
Merge pull request #589 from Aratrik-02/branch-Aratrik
gantavyamalviya2619e67
Merge pull request #588 from Abhishek-Mallick/leetcode4
gantavyamalviya719d0fe
Merge pull request #587 from GaurishIIITNR/main
gantavyamalviya2407416
Merge pull request #586 from swarup-0508/main
gantavyamalviya61e1592
Merge pull request #584 from 0901IT201046/main
gantavyamalviyad1c73b0
Merge pull request #582 from abhishekdey4444/main
gantavyamalviya9da3f02
Merge pull request #581 from DharmaWarrior/main
gantavyamalviya39a39fa
Merge pull request #580 from s-a-c-h-i-n/main
gantavyamalviyadb7e87e
Merge pull request #579 from RR190701/main
gantavyamalviyafbdbb38
Merge pull request #576 from namita27/patch-1
gantavyamalviyade8e0b9
Merge pull request #616 from sohamdata/passGen
gantavyamalviyab514f70
Merge pull request #642 from ShreyasiDebnath/main
gantavyamalviya036bd81
Merge pull request #640 from vaibhav0806/my-branch
gantavyamalviya30759cd
Merge pull request #639 from Jayesh3734/main
gantavyamalviyaf2988b7
Merge pull request #638 from GaurishIIITNR/PR5
gantavyamalviyaa33de39
Merge pull request #637 from arpitghura/main
gantavyamalviyaf9d41a3
Merge pull request #635 from AmanDekate1/patch-1
gantavyamalviya6a8c5ab
Merge pull request #634 from codeX1616/codeX1616/OverrideEqualsMethod
gantavyamalviya12a26d0
Merge pull request #633 from GaurishIIITNR/PR3
gantavyamalviya54f3455
Merge pull request #631 from vaibhav0726/patch-1
gantavyamalviya287db41
Merge pull request #629 from roy2pushkar/dsa
gantavyamalviyaf256b14
Merge pull request #628 from NarpatAanjana/main
gantavyamalviyae7548cd
Merge branch 'main' into main
gantavyamalviya9210e8c
Merge pull request #627 from vishwajeet-hogale/main
gantavyamalviya89bf45b
Merge pull request #626 from MidhaShrey/main
gantavyamalviya45e34eb
Merge pull request #625 from divyaa1511/main
gantavyamalviyaaedc265
Merge pull request #624 from ola-nishant/nishant
gantavyamalviyaaa6b500
Merge pull request #623 from Vip2016-0/LeetCodeSol
gantavyamalviyaec20cc9
Merge pull request #622 from SegFault03/main
gantavyamalviya1bce71b
Merge pull request #621 from Ultimateutkarsh11/Utkarsh-Branch
gantavyamalviyaddf0258
Merge pull request #620 from Bluetoothworks/addcode
gantavyamalviyaaf2b074
Merge pull request #619 from KBhushan07/main
gantavyamalviya1d2ad71
Merge pull request #618 from JYunth/main
gantavyamalviyae702f36
Merge pull request #617 from Ansh-Kushwaha/patch-1
gantavyamalviyaf81746e
Update README.md
gantavyamalviya12912fa
Create contributors.yml
gantavyamalviya141c22f
Update README.md
gantavyamalviya749ca26
docs(README): update contributors
github-actions[bot]e3a0413
docs(README): update contributors
github-actions[bot]3c97f65
Update README.md
gantavyamalviyabda2705
docs(README): update contributors
github-actions[bot]88ceff2
docs(README): update contributors
github-actions[bot]23e18f4
docs(README): update contributors
github-actions[bot]74db799
docs(README): update contributors
github-actions[bot]89c15a8
docs(README): update contributors
github-actions[bot]e4a0c92
docs(README): update contributors
github-actions[bot]0775771
docs(README): update contributors
github-actions[bot]1b3e09e
Update README.md
gantavyamalviyab3dc303
docs(README): update contributors
github-actions[bot]0c309b8
docs(README): update contributors
github-actions[bot]383919e
docs(README): update contributors
github-actions[bot]d17292e
docs(README): update contributors
github-actions[bot]d38f742
docs(README): update contributors
github-actions[bot]ce5db63
docs(README): update contributors
github-actions[bot]baa4263
docs(README): update contributors
github-actions[bot]035b4c3
docs(README): update contributors
github-actions[bot]a94abdf
docs(README): update contributors
github-actions[bot]773d108
docs(README): update contributors
github-actions[bot]193e35b
docs(README): update contributors
github-actions[bot]f3511a1
docs(README): update contributors
github-actions[bot]07f8a85
docs(README): update contributors
github-actions[bot]028c2bf
docs(README): update contributors
github-actions[bot]41d9101
docs(README): update contributors
github-actions[bot]fbf615f
docs(README): update contributors
github-actions[bot]44c95ae
docs(README): update contributors
github-actions[bot]92bfbf9
docs(README): update contributors
github-actions[bot]22bb2e1
docs(README): update contributors
github-actions[bot]84b6a89
docs(README): update contributors
github-actions[bot]881d8ab
docs(README): update contributors
github-actions[bot]2549b2f
docs(README): update contributors
github-actions[bot]5abac9b
docs(README): update contributors
github-actions[bot]816deb8
docs(README): update contributors
github-actions[bot]5e8f7a2
docs(README): update contributors
github-actions[bot]91ed764
docs(README): update contributors
github-actions[bot]cfaac9e
docs(README): update contributors
github-actions[bot]e275c29
docs(README): update contributors
github-actions[bot]9c93351
docs(README): update contributors
github-actions[bot]9c2b3e6
docs(README): update contributors
github-actions[bot]f893674
docs(README): update contributors
github-actions[bot]cb93523
docs(README): update contributors
github-actions[bot]9fdd0e0
docs(README): update contributors
github-actions[bot]681132e
docs(README): update contributors
github-actions[bot]a66c135
docs(README): update contributors
github-actions[bot]356fec0
docs(README): update contributors
github-actions[bot]ece47d6
docs(README): update contributors
github-actions[bot]16778bc
docs(README): update contributors
github-actions[bot]a21cc0b
docs(README): update contributors
github-actions[bot]fb819bc
docs(README): update contributors
github-actions[bot]d1b1d05
docs(README): update contributors
github-actions[bot]696676c
docs(README): update contributors
github-actions[bot]c733eba
docs(README): update contributors
github-actions[bot]d369c05
docs(README): update contributors
github-actions[bot]b4b46fc
docs(README): update contributors
github-actions[bot]44d44bf
docs(README): update contributors
github-actions[bot]2c51424
docs(README): update contributors
github-actions[bot]bdcf79d
docs(README): update contributors
github-actions[bot]f672d5d
docs(README): update contributors
github-actions[bot]40518ef
docs(README): update contributors
github-actions[bot]a7375a0
docs(README): update contributors
github-actions[bot]723ad1c
docs(README): update contributors
github-actions[bot]84dc84a
docs(README): update contributors
github-actions[bot]42b54ef
docs(README): update contributors
github-actions[bot]62bd760
docs(README): update contributors
github-actions[bot]bb967dc
docs(README): update contributors
github-actions[bot]a671ee2
docs(README): update contributors
github-actions[bot]ee53910
docs(README): update contributors
github-actions[bot]e6f6d4c
docs(README): update contributors
github-actions[bot]0237346
docs(README): update contributors
github-actions[bot]7260fec
docs(README): update contributors
github-actions[bot]94cdb32
docs(README): update contributors
github-actions[bot]e8f15b2
docs(README): update contributors
github-actions[bot]a6383a3
docs(README): update contributors
github-actions[bot]d66fb5c
docs(README): update contributors
github-actions[bot]a8dd8bc
docs(README): update contributors
github-actions[bot]6306e43
docs(README): update contributors
github-actions[bot]ff15c27
docs(README): update contributors
github-actions[bot]7242b2f
docs(README): update contributors
github-actions[bot]9743fe6
docs(README): update contributors
github-actions[bot]c0cd2ac
docs(README): update contributors
github-actions[bot]06ec62b
docs(README): update contributors
github-actions[bot]350a65b
docs(README): update contributors
github-actions[bot]a8184e3
docs(README): update contributors
github-actions[bot]20966c6
docs(README): update contributors
github-actions[bot]a03b9fb
docs(README): update contributors
github-actions[bot]d202442
docs(README): update contributors
github-actions[bot]f7572e4
docs(README): update contributors
github-actions[bot]6387625
docs(README): update contributors
github-actions[bot]a151deb
Merge pull request #1 from codemistic/main
Ansari-ShamailaFile filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
The table of contents is too big for display.
Diff view
Diff view
Uh oh!
There was an error while loading.Please reload this page.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions.github/workflows/contributors.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
name: Add contributors | ||
on: | ||
schedule: | ||
- cron: '20 20 * * *' | ||
push: | ||
branches: | ||
- main | ||
jobs: | ||
add-contributors: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- uses: BobAnkh/add-contributors@master | ||
with: | ||
CONTRIBUTOR: '### Contributors' | ||
COLUMN_PER_ROW: '6' | ||
ACCESS_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
IMG_WIDTH: '100' | ||
FONT_SIZE: '14' | ||
PATH: '/README.md' | ||
COMMIT_MESSAGE: 'docs(README): update contributors' | ||
AVATAR_SHAPE: 'round' |
19 changes: 19 additions & 0 deletions1048-longest-string-chain/1048-longest-string-chain.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Solution { | ||
public int longestStrChain(String[] words) { | ||
Map<String,Integer> map = new HashMap<>(); | ||
Arrays.sort(words, (a,b)->a.length() - b.length()); | ||
int res = 0; | ||
for(String word : words) | ||
{ | ||
int best = 0; | ||
for(int i=0;i<word.length();i++) | ||
{ | ||
String prev = word.substring(0,i) + word.substring(i+1); | ||
best = Math.max(best,map.getOrDefault(prev,0)+1); | ||
} | ||
map.put(word,best); | ||
res = Math.max(res,best); | ||
} | ||
return res; | ||
} | ||
} |
44 changes: 44 additions & 0 deletions1048-longest-string-chain/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<h2><a href="https://leetcode.com/problems/longest-string-chain/">1048. Longest String Chain</a></h2><h3>Medium</h3><hr><div><p>You are given an array of <code>words</code> where each word consists of lowercase English letters.</p> | ||
<p><code>word<sub>A</sub></code> is a <strong>predecessor</strong> of <code>word<sub>B</sub></code> if and only if we can insert <strong>exactly one</strong> letter anywhere in <code>word<sub>A</sub></code> <strong>without changing the order of the other characters</strong> to make it equal to <code>word<sub>B</sub></code>.</p> | ||
<ul> | ||
<li>For example, <code>"abc"</code> is a <strong>predecessor</strong> of <code>"ab<u>a</u>c"</code>, while <code>"cba"</code> is not a <strong>predecessor</strong> of <code>"bcad"</code>.</li> | ||
</ul> | ||
<p>A <strong>word chain</strong><em> </em>is a sequence of words <code>[word<sub>1</sub>, word<sub>2</sub>, ..., word<sub>k</sub>]</code> with <code>k >= 1</code>, where <code>word<sub>1</sub></code> is a <strong>predecessor</strong> of <code>word<sub>2</sub></code>, <code>word<sub>2</sub></code> is a <strong>predecessor</strong> of <code>word<sub>3</sub></code>, and so on. A single word is trivially a <strong>word chain</strong> with <code>k == 1</code>.</p> | ||
<p>Return <em>the <strong>length</strong> of the <strong>longest possible word chain</strong> with words chosen from the given list of </em><code>words</code>.</p> | ||
<p> </p> | ||
<p><strong>Example 1:</strong></p> | ||
<pre><strong>Input:</strong> words = ["a","b","ba","bca","bda","bdca"] | ||
<strong>Output:</strong> 4 | ||
<strong>Explanation</strong>: One of the longest word chains is ["a","<u>b</u>a","b<u>d</u>a","bd<u>c</u>a"]. | ||
</pre> | ||
<p><strong>Example 2:</strong></p> | ||
<pre><strong>Input:</strong> words = ["xbc","pcxbcf","xb","cxbc","pcxbc"] | ||
<strong>Output:</strong> 5 | ||
<strong>Explanation:</strong> All the words can be put in a word chain ["xb", "xb<u>c</u>", "<u>c</u>xbc", "<u>p</u>cxbc", "pcxbc<u>f</u>"]. | ||
</pre> | ||
<p><strong>Example 3:</strong></p> | ||
<pre><strong>Input:</strong> words = ["abcd","dbqca"] | ||
<strong>Output:</strong> 1 | ||
<strong>Explanation:</strong> The trivial word chain ["abcd"] is one of the longest word chains. | ||
["abcd","dbqca"] is not a valid word chain because the ordering of the letters is changed. | ||
</pre> | ||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
<ul> | ||
<li><code>1 <= words.length <= 1000</code></li> | ||
<li><code>1 <= words[i].length <= 16</code></li> | ||
<li><code>words[i]</code> only consists of lowercase English letters.</li> | ||
</ul> | ||
</div> |
19 changes: 19 additions & 0 deletions121 Leetcode/114-flatten-binary-tree-to-linked-list.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Solution { | ||
public: | ||
void flatten(TreeNode* root) { | ||
if(!root) return; | ||
while(root) | ||
{ | ||
TreeNode* temp = root->right; | ||
root->right = root->left; | ||
root->left = NULL; | ||
TreeNode* node = root; | ||
while(node->right) | ||
{ | ||
node = node->right; | ||
} | ||
node->right = temp; | ||
root = root->right; | ||
} | ||
} | ||
}; |
10 changes: 10 additions & 0 deletions121 Leetcode/121 leetcode.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Solution: | ||
def maxProfit(self, prices: List[int]) -> int: | ||
maxProfit = 0 | ||
currentMax = 0 | ||
for i in reversed(prices): | ||
currentMax = max(currentMax, i) | ||
profit = currentMax - i | ||
maxProfit = max(profit, maxProfit) | ||
return maxProfit |
101 changes: 101 additions & 0 deletions121 Leetcode/word-ladder-ii.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
// BFS gives TLE if we store path while traversing because whenever we find a better visit time for a word, we have to clear/make a new path vector everytime. | ||
// The idea is to first use BFS to search from beginWord to endWord and generate the word-to-children mapping at the same time. | ||
// Then, use DFS (backtracking) to generate the transformation sequences according to the mapping. | ||
// The reverse DFS allows us to only make the shortest paths, never having to clear a whole sequence when we encounter better result in BFS | ||
// No string operations are done, by dealing with indices instead. | ||
class Solution { | ||
public: | ||
bool able(string s,string t){ | ||
int c=0; | ||
for(int i=0;i<s.length();i++) | ||
c+=(s[i]!=t[i]); | ||
return c==1; | ||
} | ||
void bfs(vector<vector<int>> &g,vector<int> parent[],int n,int start,int end){ | ||
vector <int> dist(n,1005); | ||
queue <int> q; | ||
q.push(start); | ||
parent[start]={-1}; | ||
dist[start]=0; | ||
while(!q.empty()){ | ||
int x=q.front(); | ||
q.pop(); | ||
for(int u:g[x]){ | ||
if(dist[u]>dist[x]+1){ | ||
dist[u]=dist[x]+1; | ||
q.push(u); | ||
parent[u].clear(); | ||
parent[u].push_back(x); | ||
} | ||
else if(dist[u]==dist[x]+1) | ||
parent[u].push_back(x); | ||
} | ||
} | ||
} | ||
void shortestPaths(vector<vector<int>> &Paths, vector<int> &path, vector<int> parent[],int node){ | ||
if(node==-1){ | ||
// as parent of start was -1, we've completed the backtrack | ||
Paths.push_back(path); | ||
return ; | ||
} | ||
for(auto u:parent[node]){ | ||
path.push_back(u); | ||
shortestPaths(Paths,path,parent,u); | ||
path.pop_back(); | ||
} | ||
} | ||
vector<vector<string>> findLadders(string beginWord, string endWord, vector<string>& wordList) { | ||
// start and end are indices of beginWord and endWord | ||
int n=wordList.size(),start=-1,end=-1; | ||
vector<vector<string>> ANS; | ||
for(int i=0;i<n;i++){ | ||
if(wordList[i]==beginWord) | ||
start=i; | ||
if(wordList[i]==endWord) | ||
end=i; | ||
} | ||
// if endWord doesn't exist, return empty list | ||
if(end==-1) | ||
return ANS; | ||
// if beginWord doesn't exist, add it in start of WordList | ||
if(start==-1){ | ||
wordList.emplace(wordList.begin(),beginWord); | ||
start=0; | ||
end++; | ||
n++; | ||
} | ||
// for each word, we're making adjency list of neighbour words (words that can be made with one letter change) | ||
// Paths will store all the shortest paths (formed later by backtracking) | ||
vector<vector<int>> g(n,vector<int>()),Paths; | ||
// storing possible parents for each word (to backtrack later), path is the current sequence (while backtracking) | ||
vector<int> parent[n],path; | ||
// creating adjency list for each pair of words in the wordList (including beginword) | ||
for(int i=0;i<n-1;i++) | ||
for(int j=i+1;j<n;j++) | ||
if(able(wordList[i],wordList[j])){ | ||
g[i].push_back(j); | ||
g[j].push_back(i); | ||
} | ||
bfs(g,parent,n,start,end); | ||
// backtracking to make shortestpaths | ||
shortestPaths(Paths,path,parent,end); | ||
for(auto u:Paths){ | ||
vector <string> now; | ||
for(int i=0;i<u.size()-1;i++) | ||
now.push_back(wordList[u[i]]); | ||
reverse(now.begin(),now.end()); | ||
now.push_back(wordList[end]); | ||
ANS.push_back(now); | ||
} | ||
return ANS; | ||
} | ||
}; |
8 changes: 8 additions & 0 deletions1480-running-sum-of-1d-array/1480-running-sum-of-1d-array.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Solution { | ||
public: | ||
vector<int> runningSum(vector<int>& nums) { | ||
for(int i=1;i<nums.size();i++) | ||
nums[i]+= nums[i-1]; | ||
return nums; | ||
} | ||
}; |
7 changes: 7 additions & 0 deletions1480-running-sum-of-1d-array/1480-running-sum-of-1d-array.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Solution { | ||
public int[] runningSum(int[] nums) { | ||
for(int i=1;i<nums.length;i++) | ||
nums[i]+=nums[i-1]; | ||
return nums; | ||
} | ||
} |
1 change: 1 addition & 0 deletions1480-running-sum-of-1d-array/NOTES.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
30 changes: 30 additions & 0 deletions1480-running-sum-of-1d-array/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<h2><a href="https://leetcode.com/problems/running-sum-of-1d-array/">1480. Running Sum of 1d Array</a></h2><h3>Easy</h3><hr><div><p>Given an array <code>nums</code>. We define a running sum of an array as <code>runningSum[i] = sum(nums[0]…nums[i])</code>.</p> | ||
<p>Return the running sum of <code>nums</code>.</p> | ||
<p> </p> | ||
<p><strong>Example 1:</strong></p> | ||
<pre><strong>Input:</strong> nums = [1,2,3,4] | ||
<strong>Output:</strong> [1,3,6,10] | ||
<strong>Explanation:</strong> Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4].</pre> | ||
<p><strong>Example 2:</strong></p> | ||
<pre><strong>Input:</strong> nums = [1,1,1,1,1] | ||
<strong>Output:</strong> [1,2,3,4,5] | ||
<strong>Explanation:</strong> Running sum is obtained as follows: [1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1].</pre> | ||
<p><strong>Example 3:</strong></p> | ||
<pre><strong>Input:</strong> nums = [3,1,2,10,1] | ||
<strong>Output:</strong> [3,4,6,16,17] | ||
</pre> | ||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
<ul> | ||
<li><code>1 <= nums.length <= 1000</code></li> | ||
<li><code>-10^6 <= nums[i] <= 10^6</code></li> | ||
</ul></div> |
16 changes: 16 additions & 0 deletions1642-furthest-building-you-can-reach/1642-furthest-building-you-can-reach.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
class Solution { | ||
public int furthestBuilding(int[] heights, int bricks, int ladders) { | ||
PriorityQueue<Integer> pq = new PriorityQueue<>(); | ||
for(int i=0;i<heights.length-1;i++) | ||
{ | ||
int distance = heights[i+1] - heights[i]; | ||
if(distance>0) | ||
pq.add(distance); | ||
if(pq.size()>ladders) | ||
bricks -= pq.poll(); | ||
if(bricks<0) | ||
return i; | ||
} | ||
return heights.length-1; | ||
} | ||
} |
1 change: 1 addition & 0 deletions1642-furthest-building-you-can-reach/NOTES.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
48 changes: 48 additions & 0 deletions1642-furthest-building-you-can-reach/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<h2><a href="https://leetcode.com/problems/furthest-building-you-can-reach/">1642. Furthest Building You Can Reach</a></h2><h3>Medium</h3><hr><div><p>You are given an integer array <code>heights</code> representing the heights of buildings, some <code>bricks</code>, and some <code>ladders</code>.</p> | ||
<p>You start your journey from building <code>0</code> and move to the next building by possibly using bricks or ladders.</p> | ||
<p>While moving from building <code>i</code> to building <code>i+1</code> (<strong>0-indexed</strong>),</p> | ||
<ul> | ||
<li>If the current building's height is <strong>greater than or equal</strong> to the next building's height, you do <strong>not</strong> need a ladder or bricks.</li> | ||
<li>If the current building's height is <b>less than</b> the next building's height, you can either use <strong>one ladder</strong> or <code>(h[i+1] - h[i])</code> <strong>bricks</strong>.</li> | ||
</ul> | ||
<p><em>Return the furthest building index (0-indexed) you can reach if you use the given ladders and bricks optimally.</em></p> | ||
<p> </p> | ||
<p><strong>Example 1:</strong></p> | ||
<img alt="" src="https://assets.leetcode.com/uploads/2020/10/27/q4.gif" style="width: 562px; height: 561px;"> | ||
<pre><strong>Input:</strong> heights = [4,2,7,6,9,14,12], bricks = 5, ladders = 1 | ||
<strong>Output:</strong> 4 | ||
<strong>Explanation:</strong> Starting at building 0, you can follow these steps: | ||
- Go to building 1 without using ladders nor bricks since 4 >= 2. | ||
- Go to building 2 using 5 bricks. You must use either bricks or ladders because 2 < 7. | ||
- Go to building 3 without using ladders nor bricks since 7 >= 6. | ||
- Go to building 4 using your only ladder. You must use either bricks or ladders because 6 < 9. | ||
It is impossible to go beyond building 4 because you do not have any more bricks or ladders. | ||
</pre> | ||
<p><strong>Example 2:</strong></p> | ||
<pre><strong>Input:</strong> heights = [4,12,2,7,3,18,20,3,19], bricks = 10, ladders = 2 | ||
<strong>Output:</strong> 7 | ||
</pre> | ||
<p><strong>Example 3:</strong></p> | ||
<pre><strong>Input:</strong> heights = [14,3,19,3], bricks = 17, ladders = 0 | ||
<strong>Output:</strong> 3 | ||
</pre> | ||
<p> </p> | ||
<p><strong>Constraints:</strong></p> | ||
<ul> | ||
<li><code>1 <= heights.length <= 10<sup>5</sup></code></li> | ||
<li><code>1 <= heights[i] <= 10<sup>6</sup></code></li> | ||
<li><code>0 <= bricks <= 10<sup>9</sup></code></li> | ||
<li><code>0 <= ladders <= heights.length</code></li> | ||
</ul> | ||
</div> |
35 changes: 35 additions & 0 deletions19-remove-nth-node-from-end-of-list.cpp/19-remove-nth-node-from-end-of-list.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* Definition for singly-linked list. | ||
* struct ListNode { | ||
* int val; | ||
* ListNode *next; | ||
* ListNode() : val(0), next(nullptr) {} | ||
* ListNode(int x) : val(x), next(nullptr) {} | ||
* ListNode(int x, ListNode *next) : val(x), next(next) {} | ||
* }; | ||
*/ | ||
class Solution { | ||
public: | ||
ListNode* removeNthFromEnd(ListNode* head, int n) { | ||
int cnt=0; | ||
ListNode* curr=head; | ||
while(curr){ | ||
curr=curr->next; | ||
cnt++; | ||
}curr=head; | ||
if(n==1 && cnt==1) | ||
return NULL; | ||
if(cnt-n==0) | ||
return head->next; | ||
for(int i=1;i<cnt-n;i++){ | ||
curr=curr->next; | ||
} | ||
if(curr->next==NULL) | ||
return head; | ||
if(curr->next->next==NULL) | ||
curr->next=NULL; | ||
else | ||
curr->next=curr->next->next; | ||
return head; | ||
} | ||
}; |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.