Skip to content

Commit 9b9ebe0

Browse files
Added shuffle-the-array.java & Modified README.md (#118)
* Added shuffle-the-array Problem * Updated README.md * Updated README.md * Modified shuffle-the-array.java * Added generate-a-string-with-characters-that-have-odd-counts.java problem Co-authored-by: Gourav Rusiya <[email protected]>
1 parent 50a97b9 commit 9b9ebe0

File tree

3 files changed

+42
-0
lines changed

3 files changed

+42
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
class Solution {
2+
public String generateTheString(int n) {
3+
String result = "";
4+
if(n % 2 == 0) {
5+
for(int i = 1; i <= n - 1; i++) {
6+
result = result + 'x';
7+
}
8+
9+
result = result + 'y';
10+
}
11+
else {
12+
for (int i = 1; i <= n; i++)
13+
{
14+
result = result + 'x';
15+
}
16+
}
17+
18+
return result;
19+
}
20+
21+
}

Java/shuffle-the-array.java

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
class Solution {
2+
public int[] shuffle(int[] nums, int n) {
3+
int [] result = new int[2 * n];
4+
5+
// Looping over the array
6+
for(int i = 0; i < 2 * n; i ++){
7+
// If the array index is even
8+
if(i % 2 == 0)
9+
result[i] = nums[i / 2];
10+
11+
// If it's not even, its odd
12+
else
13+
result[i] = nums[n + i / 2];
14+
}
15+
16+
return result;
17+
}
18+
}

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ Check out ---> [Sample PR](https://github.com/codedecks-in/LeetCode-Solutions/pu
123123
| 1288 | [Remove-Covered-Intervals](https://leetcode.com/problems/remove-covered-intervals) | [C++](./C++/Remove-Covered-Intervals.cpp) | O(N*N) | O(1) | Medium | Array |
124124
| 189 | [Rotate-Array](https://leetcode.com/problems/rotate-array/) | [Python](./Python/rotate-array.py) | O(N) | O(1) | Medium | Array
125125
| 496 | [next-greater-element-i](https://leetcode.com/problems/next-greater-element-i) | [Python](./Python/496_nextgreaterelement.py) | O(N) | O(1) | Medium | Array
126+
| 1470 | [Shuffle the Array](https://leetcode.com/problems/shuffle-the-array) | [Java](./Java/shuffle-the-array.java) | O(N) | O(1) | Easy | Array
126127

127128

128129
<br/>
@@ -141,6 +142,7 @@ Check out ---> [Sample PR](https://github.com/codedecks-in/LeetCode-Solutions/pu
141142
| 520 | [Detect Capital Use](https://leetcode.com/problems/detect-capital/) | [Java](./Java/detect-capital-use.java) | _O(n)_ | _O(1)_ | Easy | | |
142143
| 1221 | [Split a String in Balanced Strings](https://leetcode.com/problems/split-a-string-in-balanced-strings/) | [Python](./Python/split-a-string-in-balanced-strings.py) | _O(n)_ | _O(1)_ | Easy | | |
143144
| 1614 | [Maximum Nesting Depth of the Parentheses](https://leetcode.com/problems/maximum-nesting-depth-of-the-parentheses/) | [Java](./Java/max-nesting-depth-parentheses.java) | _O(n)_ | _O(1)_ | Easy | | |
145+
| 1374 | [Generate a String With Characters That Have Odd Counts](https://leetcode.com/problems/generate-a-string-with-characters-that-have-odd-counts/) | [Java](./Java/generate-a-string-with-characters-that-have-odd-counts.java) | _O(n)_ | _O(1)_ | Easy | | |
144146

145147
<br/>
146148
<div align="right">
@@ -430,6 +432,7 @@ DISCLAIMER: This above mentioned resources have affiliate links, which means if
430432
| [Ilias Khan](https://github.com/IliasKhan) <br> <img src="https://avatars3.githubusercontent.com/u/26863936?s=460&u=4501ffba5efd1a7b978416e8e434dff599c85384&v=4" width="100" height="100"> | India | C++ | [codechef](https://www.codechef.com/users/iliaskhan) <br> [Hackerrank](ckerrank.com/iliaskhan57) <br> [LeetCode](https://leetcode.com/ilias_khan/) <br> [codeforces](http://codeforces.com/profile/iliaskhan) |
431433
| [Shamoyeeta Saha](https://github.com/Shamoyeeta) <br> <img src="https://i.pinimg.com/236x/dc/ef/3a/dcef3abedf0e0761203aaeb85886a6f3--jedi-knight-open-source.jpg" width="100" height="100"> | India | C++ | [Hackerrank](https://www.hackerrank.com/sahashamoyeeta) <br> [Github](https://github.com/Shamoyeeta) |
432434
| [James Y](https://github.com/jameszu) <br> <img src="https://avatars0.githubusercontent.com/u/41566813?s=400&u=af77d15517566ea590a316030b4a6d402b0041b6&v=4" width="100" height="100"> | New Zealand | python | [Github](https://github.com/jameszu) |
435+
| [Hamza B](https://github.com/9Hamza) <br> <img src="https://avatars2.githubusercontent.com/u/56516922?s=400&u=2c1adeef0194a2859361d464f28783bfba698638&v=4" width="100" height="100"> | Saudi Arabia | Java | [Github](https://github.com/9Hamza) |
433436
| [Meli Haktas](https://github.com/MercerFrey) <br> <img src="https://avatars1.githubusercontent.com/u/29127873?s=460&u=149319db4468ec2316e49a75eb5e05b35eb05eef&v=4" width="100" height="100"> | Turkey | python | [Github](https://github.com/MercerFrey) |
434437

435438
<br/>

0 commit comments

Comments
 (0)