question_slug stringlengths 3 77 | title stringlengths 1 183 | slug stringlengths 12 45 | summary stringlengths 1 160 ⌀ | author stringlengths 2 30 | certification stringclasses 2
values | created_at stringdate 2013-10-25 17:32:12 2025-04-12 09:38:24 | updated_at stringdate 2013-10-25 17:32:12 2025-04-12 09:38:24 | hit_count int64 0 10.6M | has_video bool 2
classes | content stringlengths 4 576k | upvotes int64 0 11.5k | downvotes int64 0 358 | tags stringlengths 2 193 | comments int64 0 2.56k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
print-in-order | Using Conditional Variables and lock :: std:: C++ Easy sol | using-conditional-variables-and-lock-std-7q79 | \n\n# Code\n\nclass Foo {\n std:: mutex m;\n std:: condition_variable cv;\n int turn;\npublic:\n Foo() {\n turn= 0;\n }\n\n void first( | ankush20386 | NORMAL | 2024-03-16T06:01:17.812087+00:00 | 2024-03-16T06:01:17.812111+00:00 | 1,124 | false | \n\n# Code\n```\nclass Foo {\n std:: mutex m;\n std:: condition_variable cv;\n int turn;\npublic:\n Foo() {\n turn= 0;\n }\n\n void first(function<void()> printFirst) {\n \n // printFirst() outputs "first". Do not change or remove this line.\n printFirst();\n ... | 3 | 0 | ['C++'] | 2 |
print-in-order | Semaphore solution | semaphore-solution-by-oskardp-ivbd | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | OskarDP | NORMAL | 2023-09-21T10:09:23.316207+00:00 | 2023-09-21T10:09:23.316234+00:00 | 507 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 3 | 0 | ['C#'] | 1 |
print-in-order | C# | Faster than 100% (90ms) | TaskCompletionSource | Rightest Solution 🟢 | c-faster-than-100-90ms-taskcompletionsou-qiq9 | Code\n\nusing System.Threading.Tasks;\npublic class Foo {\n private TaskCompletionSource _f;\n private TaskCompletionSource _s;\n \n public Foo()\n | Encapsulating | NORMAL | 2023-07-31T08:56:01.852615+00:00 | 2023-07-31T08:56:01.852632+00:00 | 424 | false | # Code\n```\nusing System.Threading.Tasks;\npublic class Foo {\n private TaskCompletionSource _f;\n private TaskCompletionSource _s;\n \n public Foo()\n {\n _f = new TaskCompletionSource();\n _s = new TaskCompletionSource();\n }\n\n public void First(Action printFirst) {\n prin... | 3 | 0 | ['C#'] | 0 |
print-in-order | [C++]Simple solution using mutex. | csimple-solution-using-mutex-by-bigbigbi-f5ts | I am a newbie about concurrency. Is this right way?\n\n# Code\n\n\n\nclass Foo {\nprivate:\n mutex task1, task2;\npublic:\n Foo() {\n task1.lock(); | bigbigbige | NORMAL | 2023-02-26T05:28:40.708280+00:00 | 2023-02-26T05:32:09.186152+00:00 | 1,083 | false | I am a newbie about concurrency. Is this right way?\n\n# Code\n```\n\n\nclass Foo {\nprivate:\n mutex task1, task2;\npublic:\n Foo() {\n task1.lock();\n task2.lock();\n }\n\n void first(function<void()> printFirst) {\n \n // printFirst() outputs "first". Do not change or remove t... | 3 | 0 | ['C++'] | 1 |
print-in-order | JAVA solution using Semaphore | java-solution-using-semaphore-by-samiksh-q33s | Complexity\n- Time complexity:\nO(1)\n\n- Space complexity:\nO(1)\n\n# Code\n\nclass Foo {\n\n Semaphore first;\n Semaphore second;\n Semaphore third;\ | samiksha12 | NORMAL | 2022-11-17T06:35:08.017648+00:00 | 2022-11-17T06:35:17.933818+00:00 | 1,171 | false | # Complexity\n- Time complexity:\nO(1)\n\n- Space complexity:\nO(1)\n\n# Code\n```\nclass Foo {\n\n Semaphore first;\n Semaphore second;\n Semaphore third;\n public Foo() {\n first = new Semaphore(1);\n second = new Semaphore(0);\n third = new Semaphore(0);\n }\n\n public void fir... | 3 | 0 | ['Java'] | 0 |
print-in-order | Java Phaser | java-phaser-by-arodin-35jm | Code\n\nclass Foo {\n private Phaser phaser = new Phaser(3);\n\n public Foo() { }\n\n public void first(Runnable printFirst) throws InterruptedExceptio | arodin | NORMAL | 2022-11-08T02:20:46.630686+00:00 | 2022-11-08T02:20:46.630721+00:00 | 443 | false | # Code\n```\nclass Foo {\n private Phaser phaser = new Phaser(3);\n\n public Foo() { }\n\n public void first(Runnable printFirst) throws InterruptedException {\n // printFirst.run() outputs "first". Do not change or remove this line.\n printFirst.run();\n phaser.arriveAndDeregister();\n ... | 3 | 0 | ['Java'] | 1 |
print-in-order | [C#] blocking threads with AutoResetEvent primitives | c-blocking-threads-with-autoresetevent-p-vcwi | Intuition\nFirst thing that came to my mind was to block second, then third method until prefious will be completed\n\n# Approach\nI decided to block set blocke | poltaratskiy | NORMAL | 2022-10-29T13:34:08.129564+00:00 | 2022-10-29T13:34:08.129607+00:00 | 803 | false | # Intuition\nFirst thing that came to my mind was to block second, then third method until prefious will be completed\n\n# Approach\nI decided to block set blockers in second and third methods. We create 2 blockers in nonsignal state, that means the method WaitOne() will block threads. \n\nMethod First() without blocke... | 3 | 0 | ['C#'] | 0 |
print-in-order | Java Real Simple Solution | java-real-simple-solution-by-ahead4-f8h2 | \nclass Foo {\n private volatile int num = 1;\n public Foo() {\n\n }\n\n public void first(Runnable printFirst) throws InterruptedException {\n | ahead4 | NORMAL | 2022-09-05T07:09:31.539817+00:00 | 2022-09-07T07:57:37.842225+00:00 | 1,288 | false | ```\nclass Foo {\n private volatile int num = 1;\n public Foo() {\n\n }\n\n public void first(Runnable printFirst) throws InterruptedException {\n while(num != 1){\n }\n\n // printFirst.run() outputs "first". Do not change or remove this line.\n printFirst.run();\n num++;\... | 3 | 0 | ['Java'] | 0 |
print-in-order | Semaphore Solution | Simple Java code | semaphore-solution-simple-java-code-by-i-apfl | \nclass Foo {\n\n private Semaphore forTwo;\n private Semaphore forThree;\n \n public Foo() {\n forTwo = new Semaphore(0);\n forThree | ishan_aggarwal | NORMAL | 2022-08-20T17:09:33.865763+00:00 | 2022-08-20T17:09:33.865804+00:00 | 281 | false | ```\nclass Foo {\n\n private Semaphore forTwo;\n private Semaphore forThree;\n \n public Foo() {\n forTwo = new Semaphore(0);\n forThree = new Semaphore(0);\n }\n\n\n \n public void first(Runnable printFirst) throws InterruptedException {\n \n // printFirst.run() outputs... | 3 | 0 | [] | 1 |
print-in-order | Brainless solution using time.sleep | brainless-solution-using-timesleep-by-us-v4he | Here is my simplest and brainless solution using time.sleep. Why and How did I think of it? People use this approach in automation where I work.\n\nPython3\nfro | useraccessdenied | NORMAL | 2022-05-06T11:05:33.298079+00:00 | 2022-05-06T11:05:33.298105+00:00 | 509 | false | Here is my simplest and brainless solution using time.sleep. Why and How did I think of it? People use this approach in automation where I work.\n\n```Python3\nfrom time import sleep\n\nclass Foo:\n def __init__(self):\n pass\n\n\n def first(self, printFirst: \'Callable[[], None]\') -> None:\n \n ... | 3 | 0 | ['Python'] | 1 |
print-in-order | 2-Lines Python Solution || 75% Faster || Memory less than 95% | 2-lines-python-solution-75-faster-memory-ln4i | \nclass Foo:\n is_first_executed=False\n is_second_executed=False\n def __init__(self):\n pass\n\n def first(self, printFirst):\n prin | Taha-C | NORMAL | 2022-03-16T23:35:19.274428+00:00 | 2022-03-16T23:35:19.274453+00:00 | 943 | false | ```\nclass Foo:\n is_first_executed=False\n is_second_executed=False\n def __init__(self):\n pass\n\n def first(self, printFirst):\n printFirst()\n self.is_first_executed=True\n\n def second(self, printSecond):\n while not self.is_first_executed: continue \n printSe... | 3 | 0 | ['Python', 'Python3'] | 1 |
print-in-order | C++ | zero semaphore with comments | c-zero-semaphore-with-comments-by-spyole-ysxz | \n#include<semaphore.h>\nclass Foo {\npublic:\n sem_t sem1;\n sem_t sem2;\n Foo() {\n sem_init(&sem1,0,0);\n sem_init(&sem2,0,0);\n | spyole97 | NORMAL | 2022-01-25T20:55:34.225264+00:00 | 2022-01-25T21:00:17.139972+00:00 | 362 | false | ```\n#include<semaphore.h>\nclass Foo {\npublic:\n sem_t sem1;\n sem_t sem2;\n Foo() {\n sem_init(&sem1,0,0);\n sem_init(&sem2,0,0);\n \n }\n\n void first(function<void()> printFirst) {\n \n printFirst();\n sem_post(&sem1);// increased the value to 1 so now two c... | 3 | 0 | [] | 0 |
print-in-order | Explanation of the solution in Java | explanation-of-the-solution-in-java-by-i-hzrp | You can use a countdownlatch, semaphore, regular mutex or lock object. I noticed a solution that relied upon volatile only but that is not right. A solution wit | idmrealm | NORMAL | 2021-10-30T02:58:43.066685+00:00 | 2021-10-30T02:58:43.066726+00:00 | 262 | false | You can use a countdownlatch, semaphore, regular mutex or lock object. I noticed a solution that relied upon volatile only but that is not right. A solution without wait/notify will cause CPU churns and spinning so you must introduce that if you are serious about MT safe programming. If you choose to go with CountDownL... | 3 | 0 | [] | 0 |
print-in-order | Simple java solution | simple-java-solution-by-wolv_ad-8h2v | Using wait and notifyAll to print in order. \n``` \nvolatile int loc = 0;\n public Foo() {\n loc = 0; \n }\n\n public void first(Runnable printF | wolv_ad | NORMAL | 2021-04-29T18:31:28.478010+00:00 | 2021-04-29T18:31:28.478050+00:00 | 564 | false | Using wait and notifyAll to print in order. \n``` \nvolatile int loc = 0;\n public Foo() {\n loc = 0; \n }\n\n public void first(Runnable printFirst) throws InterruptedException {\n \n // printFirst.run() outputs "first". Do not change or remove this line.\n synchronized(this){\n ... | 3 | 0 | [] | 1 |
print-in-order | C++ MUTEX AND CONDITION VARIABLE 12MS | c-mutex-and-condition-variable-12ms-by-a-9tr6 | \nclass Foo {\n mutex m;\n condition_variable firstCond;\n condition_variable secondCond;\n condition_variable thirdCond;\n int chance;\npublic:\ | abhi_tom | NORMAL | 2021-04-11T04:37:51.030285+00:00 | 2021-04-11T04:37:51.030320+00:00 | 346 | false | ```\nclass Foo {\n mutex m;\n condition_variable firstCond;\n condition_variable secondCond;\n condition_variable thirdCond;\n int chance;\npublic:\n Foo() {\n chance=1;\n }\n\n void first(function<void()> printFirst) {\n unique_lock<mutex> locker(m);\n \n firstCond.w... | 3 | 0 | [] | 0 |
print-in-order | [C++] simple atomics with memory order | c-simple-atomics-with-memory-order-by-ba-5eyx | \nclass Foo {\npublic:\n Foo() {\n \n }\n\n void first(function<void()> printFirst) {\n printFirst();\n a1.store(true, memory_orde | batmad | NORMAL | 2021-03-23T01:54:25.623473+00:00 | 2021-03-23T01:54:25.623515+00:00 | 542 | false | ```\nclass Foo {\npublic:\n Foo() {\n \n }\n\n void first(function<void()> printFirst) {\n printFirst();\n a1.store(true, memory_order_release);\n }\n\n void second(function<void()> printSecond) {\n while(!a1.load(std::memory_order_acquire)) this_thread::yield();\n prin... | 3 | 0 | ['C'] | 0 |
print-in-order | c++ using semaphores - short with comments | c-using-semaphores-short-with-comments-b-l6yy | \n#include <semaphore.h>\nclass Foo {\n sem_t firstSem;\n sem_t secondSem;\npublic:\n Foo() {\n\t//init two semaphores with counter = 0\n sem_in | ofir_kr | NORMAL | 2021-02-08T10:40:31.320244+00:00 | 2021-02-08T10:46:15.968911+00:00 | 374 | false | ```\n#include <semaphore.h>\nclass Foo {\n sem_t firstSem;\n sem_t secondSem;\npublic:\n Foo() {\n\t//init two semaphores with counter = 0\n sem_init(&firstSem, 0, 0);\n sem_init(&secondSem, 0, 0);\n }\n\n void first(function<void()> printFirst) {\n \n // printFirst() outputs ... | 3 | 0 | ['C'] | 3 |
print-in-order | C++ condition variable clean code easy to understand | c-condition-variable-clean-code-easy-to-rb5oi | C++\nclass Foo {\n atomic<int> cur;\n mutex mtx;\n condition_variable cv;\nprotected:\n void do_work(function<void()> printS, function<bool()> check | lzqgeorge | NORMAL | 2021-01-25T01:18:11.797415+00:00 | 2021-01-25T01:18:11.797451+00:00 | 740 | false | ```C++\nclass Foo {\n atomic<int> cur;\n mutex mtx;\n condition_variable cv;\nprotected:\n void do_work(function<void()> printS, function<bool()> check) {\n std::unique_lock<mutex> lk(mtx);\n cv.wait(lk, [&]{return check();});\n \n cur = (cur+1)%4;\n printS();\n cv.... | 3 | 0 | ['C', 'C++'] | 0 |
print-in-order | C# Monitor Wait & PulseAll | c-monitor-wait-pulseall-by-1988hz-y1ke | \nusing System.Threading; \n\npublic class Foo\n {\n class Lock\n {\n public int Step;\n }\n\n static Lock _Lock = new | 1988hz | NORMAL | 2021-01-10T03:43:07.864863+00:00 | 2021-01-10T03:43:07.864889+00:00 | 249 | false | ```\nusing System.Threading; \n\npublic class Foo\n {\n class Lock\n {\n public int Step;\n }\n\n static Lock _Lock = new Lock(){ Step = 0 };\n\n public Foo()\n {\n\n }\n\n public void First(Action printFirst)\n {\n lock (_Lock)\n ... | 3 | 1 | [] | 0 |
print-in-order | Python solution without using additional libraries | python-solution-without-using-additional-463f | \nclass Foo:\n def __init__(self):\n self._first = False\n self._second = False\n\n\n def first(self, printFirst: \'Callable[[], None]\') -> | bluebadger | NORMAL | 2020-12-06T01:49:06.473200+00:00 | 2020-12-06T01:49:06.473225+00:00 | 469 | false | ```\nclass Foo:\n def __init__(self):\n self._first = False\n self._second = False\n\n\n def first(self, printFirst: \'Callable[[], None]\') -> None:\n \n # printFirst() outputs "first". Do not change or remove this line.\n printFirst()\n self._first = True\n\n\n def s... | 3 | 0 | [] | 0 |
print-in-order | CountDownLatch Java | countdownlatch-java-by-_gauravgupta-bgjq | \nclass Foo {\n\n private CountDownLatch latch1 = new CountDownLatch(1);\n private CountDownLatch latch2 = new CountDownLatch(1);\n \n public Foo() {\ | _gauravgupta | NORMAL | 2020-11-19T17:26:26.367809+00:00 | 2020-11-19T17:26:26.367839+00:00 | 216 | false | ```\nclass Foo {\n\n private CountDownLatch latch1 = new CountDownLatch(1);\n private CountDownLatch latch2 = new CountDownLatch(1);\n \n public Foo() {\n \n }\n\n public void first(Runnable printFirst) throws InterruptedException {\n \n // printFirst.run() outputs "first". Do not c... | 3 | 0 | [] | 0 |
print-in-order | C++ Solution Using 2 mutexes | c-solution-using-2-mutexes-by-yehudisk-gtz4 | \nclass Foo {\npublic:\n Foo() {\n pthread_mutex_lock(&m_second);\n pthread_mutex_lock(&m_third);\n }\n \n ~Foo() {\n pthread_m | yehudisk | NORMAL | 2020-11-18T23:26:48.431768+00:00 | 2020-11-18T23:26:48.431809+00:00 | 221 | false | ```\nclass Foo {\npublic:\n Foo() {\n pthread_mutex_lock(&m_second);\n pthread_mutex_lock(&m_third);\n }\n \n ~Foo() {\n pthread_mutex_destroy(&m_second);\n pthread_mutex_destroy(&m_third);\n }\n\n void first(function<void()> printFirst) {\n \n // printFirst()... | 3 | 0 | [] | 0 |
print-in-order | Java | Semaphore simple implementation | java-semaphore-simple-implementation-by-xa7y4 | \nclass Foo {\n \n Semaphore second = new Semaphore(0);\n Semaphore third = new Semaphore(0);\n\n public Foo() {\n \n }\n\n public void | onesubhadip | NORMAL | 2020-09-17T11:11:01.486801+00:00 | 2020-09-17T11:11:01.486843+00:00 | 384 | false | ```\nclass Foo {\n \n Semaphore second = new Semaphore(0);\n Semaphore third = new Semaphore(0);\n\n public Foo() {\n \n }\n\n public void first(Runnable printFirst) throws InterruptedException {\n \n // printFirst.run() outputs "first". Do not change or remove this line.\n ... | 3 | 0 | [] | 1 |
print-in-order | [C++] 132ms/7.2MB using std::condition_variable in a proper way | c-132ms72mb-using-stdcondition_variable-ewlxr | Example with test cases\nhttps://github.com/jimmy-park/leetcode-cpp-solution/blob/master/Concurrency/1114-Print-in-Order.h\n\n\nclass Foo {\npublic:\n void f | jiwoo_90 | NORMAL | 2020-07-26T20:47:26.001102+00:00 | 2020-07-30T11:34:50.724009+00:00 | 675 | false | Example with test cases\nhttps://github.com/jimmy-park/leetcode-cpp-solution/blob/master/Concurrency/1114-Print-in-Order.h\n\n```\nclass Foo {\npublic:\n void first(function<void()> printFirst)\n {\n // printFirst() outputs "first". Do not change or remove this line.\n printFirst();\n\n {\n ... | 3 | 0 | ['C', 'C++'] | 2 |
print-in-order | Py soln using sleep(), simple and fast | py-soln-using-sleep-simple-and-fast-by-z-g8mf | This simple solution was faster than 95.4% solutiions (32ms runtime)\n\n\n\nclass Foo:\n#flag variables \n calledFirst = 0\n calledSecond = 0\n def __i | zwicky | NORMAL | 2020-07-19T12:41:14.834222+00:00 | 2020-07-19T13:10:16.267415+00:00 | 217 | false | This simple solution was faster than 95.4% solutiions (32ms runtime)\n```\n\n\nclass Foo:\n#flag variables \n calledFirst = 0\n calledSecond = 0\n def __init__(self):\n pass\n\n\n def first(self, printFirst: \'Callable[[], None]\') -> None:\n \n #print and set flag\n printFirst()... | 3 | 1 | ['Python3'] | 0 |
groups-of-special-equivalent-strings | Java Concise Set Solution | java-concise-set-solution-by-caraxin-xpjx | For each String, we generate it\'s corresponding signature, and add it to the set.\nIn the end, we return the size of the set.\n\nclass Solution {\n public i | caraxin | NORMAL | 2018-08-26T03:01:07.888583+00:00 | 2018-10-24T13:36:01.151927+00:00 | 8,332 | false | For each String, we generate it\'s corresponding signature, and add it to the set.\nIn the end, we return the size of the set.\n```\nclass Solution {\n public int numSpecialEquivGroups(String[] A) {\n Set<String> set= new HashSet<>();\n for (String s: A){\n int[] odd= new int[26];\n ... | 127 | 0 | [] | 11 |
groups-of-special-equivalent-strings | Python 1-liner | python-1-liner-by-cenkay-8oeu | \nclass Solution:\n def numSpecialEquivGroups(self, A):\n return len(set("".join(sorted(s[0::2])) + "".join(sorted(s[1::2])) for s in A))\n | cenkay | NORMAL | 2018-08-26T07:38:06.658961+00:00 | 2018-09-23T04:15:55.200241+00:00 | 4,589 | false | ```\nclass Solution:\n def numSpecialEquivGroups(self, A):\n return len(set("".join(sorted(s[0::2])) + "".join(sorted(s[1::2])) for s in A))\n``` | 58 | 1 | [] | 7 |
groups-of-special-equivalent-strings | C++ Simple Solution | c-simple-solution-by-code_report-hkzn | General Idea:\n\n1. Split strings in two to substrings, 1 with even indexed characters, and 1 with odd\n2. Sort the two substrings (We do this because if you ca | code_report | NORMAL | 2018-08-26T03:01:07.733763+00:00 | 2018-09-24T03:47:39.591039+00:00 | 6,221 | false | **General Idea:**\n\n1. Split strings in two to substrings, 1 with even indexed characters, and 1 with odd\n2. Sort the two substrings (We do this because if you can swap on string with another, when sorted they will equal each other because they must have the same characters)\n3. Insert your pair of strings into set, ... | 55 | 0 | [] | 8 |
groups-of-special-equivalent-strings | [python3] detail explanation of special-equivalent | python3-detail-explanation-of-special-eq-x5ng | The point here is to understand the following requirement:\nA move consists of choosing two indices i and j with i % 2 == j % 2, and swapping S[i] with S[j].\nD | zhanweiting | NORMAL | 2019-08-14T22:40:16.726298+00:00 | 2019-08-14T22:44:39.425253+00:00 | 1,785 | false | * The point here is to understand the following requirement:\nA move consists of choosing two indices i and j with i % 2 == j % 2, and swapping S[i] with S[j].\nDon\'t trap your thoughts by the word \'swap\'.\nYour goal is how to identify the equivalent strings. \n* There are two possible outcomes of i%2: 1 or 0. i is ... | 40 | 0 | ['Python', 'Python3'] | 3 |
groups-of-special-equivalent-strings | Python extremely simple solution | python-extremely-simple-solution-by-wnmm-6x6b | \nclass Solution:\n\tdef numSpecialEquivGroups(self, A):\n\t\td = collections.defaultdict(int)\n\t\tfor w in A:\n\t\t\teven = \'\'.join(sorted(w[0::2]))\n\t\t\t | wnmmxy | NORMAL | 2018-08-26T04:02:20.715408+00:00 | 2018-09-05T06:19:55.777489+00:00 | 2,164 | false | ```\nclass Solution:\n\tdef numSpecialEquivGroups(self, A):\n\t\td = collections.defaultdict(int)\n\t\tfor w in A:\n\t\t\teven = \'\'.join(sorted(w[0::2]))\n\t\t\todd = \'\'.join(sorted(w[1::2]))\n\t\t\td[(even, odd)] += 1\n\t\t\n\t\treturn len(d)\n``` | 21 | 1 | [] | 4 |
groups-of-special-equivalent-strings | Straightforward Java solution | straightforward-java-solution-by-mycafeb-53p3 | map1 - the distribution of counts of the characters at even positions\nmap2 - the distribution of counts of the characters at odd positions\nset - how many uniq | mycafebabe | NORMAL | 2018-08-27T02:35:27.727517+00:00 | 2018-10-09T07:50:16.784070+00:00 | 1,499 | false | map1 - the distribution of counts of the characters at even positions\nmap2 - the distribution of counts of the characters at odd positions\nset - how many unique distributions\n\n```\nclass Solution {\n public int numSpecialEquivGroups(String[] A) {\n Set<String> set = new HashSet<>();\n for (String s... | 11 | 1 | [] | 1 |
groups-of-special-equivalent-strings | Python 3 || 5 lines, w/ example || T/S: 84% / 16% | python-3-5-lines-w-example-ts-84-16-by-s-35jj | \n\nclass Solution:\n def numSpecialEquivGroups(self, words: List[str]) -> int:\n # Example: \n | Spaulding_ | NORMAL | 2022-12-21T23:44:54.279178+00:00 | 2024-05-31T05:14:59.247328+00:00 | 791 | false | \n```\nclass Solution:\n def numSpecialEquivGroups(self, words: List[str]) -> int:\n # Example: \n wSet = set() # words = ["abc","acb","bac","bca","cab","cba"]\n\n for word in words: ... | 8 | 0 | ['Python3'] | 0 |
groups-of-special-equivalent-strings | Python O(n * k lg k) sol. by signature. 90%+ [w/ Hint] | python-on-k-lg-k-sol-by-signature-90-w-h-z5ep | Python sol. by signature. \n\n---\n\nHint:\n\nThink of the concept for anagram judgement.\n\nWhat we need in this challenge is to verify the so-called "special | brianchiang_tw | NORMAL | 2020-03-11T11:34:35.114132+00:00 | 2020-03-11T15:08:22.987904+00:00 | 857 | false | Python sol. by signature. \n\n---\n\n**Hint**:\n\nThink of the concept for **anagram** judgement.\n\nWhat we need in this challenge is to verify the so-called "**special equivalent**", \nwhich means even-indexed substring of input is anagram and odd-indexed substring of input is another anagram.\n\nWe can verify by si... | 8 | 0 | ['Ordered Set', 'Python', 'Python3'] | 2 |
groups-of-special-equivalent-strings | Python 1-liner (beats 100% of other submissions) | python-1-liner-beats-100-of-other-submis-dvd3 | The idea is to convert all strings to some sort of canonical representation. Since all characters at even and odd position can be shuffled in any way, sorting t | ttsugrii | NORMAL | 2018-08-29T06:33:18.404330+00:00 | 2018-10-24T22:11:16.299265+00:00 | 798 | false | The idea is to convert all strings to some sort of canonical representation. Since all characters at even and odd position can be shuffled in any way, sorting them will produce the desired result - strings like `cba` will be converted to `abc` and `dcba` to `badc`. Having all strings converted to their canonical form, ... | 7 | 1 | [] | 0 |
groups-of-special-equivalent-strings | C++||Set||Easy to Understand | cseteasy-to-understand-by-return_7-8qf2 | ```\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector& words)\n { \n set> s;\n for(auto &w:words)\n {\n str | return_7 | NORMAL | 2022-08-15T22:36:21.178258+00:00 | 2022-08-15T22:36:21.178293+00:00 | 441 | false | ```\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& words)\n { \n set<pair<string,string>> s;\n for(auto &w:words)\n {\n string p,q;\n for(int i=0;i<w.size();i++)\n {\n if(i%2==0)\n {\n ... | 6 | 0 | ['C', 'Ordered Set'] | 1 |
groups-of-special-equivalent-strings | JavaScript easy solution | javascript-easy-solution-by-shengdade-yt3g | javascript\n/**\n * @param {string[]} A\n * @return {number}\n */\nvar numSpecialEquivGroups = function(A) {\n const groupSet = new Set();\n A.forEach(a => gr | shengdade | NORMAL | 2020-02-17T22:39:31.755963+00:00 | 2020-02-17T22:39:31.755999+00:00 | 433 | false | ```javascript\n/**\n * @param {string[]} A\n * @return {number}\n */\nvar numSpecialEquivGroups = function(A) {\n const groupSet = new Set();\n A.forEach(a => groupSet.add(transform(a)));\n return groupSet.size;\n};\n\nconst transform = S => {\n const even = S.split(\'\').filter((_, i) => i % 2 === 0);\n const odd... | 6 | 0 | ['JavaScript'] | 0 |
groups-of-special-equivalent-strings | C# using counting sort since string contains English letters | c-using-counting-sort-since-string-conta-fp3p | Sept. 23, 2018\nIt is an easy level string algorithm. The swap of letters should be restricted to odd index or even index two groups. All letters in odd index c | jianminchen | NORMAL | 2018-09-24T03:56:02.013592+00:00 | 2020-08-19T18:47:50.012142+00:00 | 519 | false | Sept. 23, 2018\nIt is an easy level string algorithm. The swap of letters should be restricted to odd index or even index two groups. All letters in odd index can be swapped, likewise as even index. \n\n```\npublic class Solution {\n public int NumSpecialEquivGroups(string[] A)\n {\n if (A == null)... | 6 | 1 | [] | 0 |
groups-of-special-equivalent-strings | [C++] Create a signature for each string | c-create-a-signature-for-each-string-by-6cvp6 | We can quickly notice that by grouping odd and even position, sorting them and concatenating them, all the special - equivalent string will have the same signat | facelessvoid | NORMAL | 2018-08-27T12:47:04.554745+00:00 | 2018-09-25T07:46:52.493984+00:00 | 876 | false | We can quickly notice that by grouping odd and even position, sorting them and concatenating them, all the special - equivalent string will have the same signature. We can then use a hash set to capture the signature (which automatically de-duplicates) and we can return the hashset size.\nThe constraints of the problem... | 6 | 0 | [] | 1 |
groups-of-special-equivalent-strings | Set || Easy C++ || Clean Code ✅✅ | set-easy-c-clean-code-by-deepak_5910-tw73 | Approach\n Describe your approach to solving the problem. \nAfter sorting the even and odd Position characters of a string put it into a unordered set and final | Deepak_5910 | NORMAL | 2023-08-10T04:34:09.631710+00:00 | 2023-08-10T04:34:09.631736+00:00 | 301 | false | # Approach\n<!-- Describe your approach to solving the problem. -->\nAfter **sorting** the **even and odd Position characters** of a string put it into a **unordered set** and finally return the **size** of the set.\n\n# Complexity\n- Time complexity:O(N * 20 * 10 * Log(10))\n<!-- Add your time complexity here, e.g. $$... | 5 | 0 | ['C++'] | 0 |
groups-of-special-equivalent-strings | BUG IN LEETCODE ITSELF!!!! CHECK IT OUT... LOL | bug-in-leetcode-itself-check-it-out-lol-70hv4 | \n\nSubmission tab gives wrong answer and output 5. But Debug tab (and my IDE) has correct answer 1. \n\nSolution:\n\nclass Solution {\n public int numSpecia | ssemichev | NORMAL | 2019-08-16T06:27:36.353520+00:00 | 2019-11-18T06:40:13.883157+00:00 | 566 | false | \n\nSubmission tab gives wrong answer and output 5. But Debug tab (and my IDE) has correct answer 1. \n\nSolution:\n```\nclass Solution {\n public int numSpecialEquivGro... | 5 | 0 | [] | 1 |
groups-of-special-equivalent-strings | (C++) 893. Groups of Special-Equivalent Strings | c-893-groups-of-special-equivalent-strin-lefd | \n\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& A) {\n unordered_set<string> seen; \n for (auto word : A) {\n | qeetcode | NORMAL | 2021-04-17T02:54:26.391804+00:00 | 2021-04-17T02:54:26.391833+00:00 | 383 | false | \n```\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& A) {\n unordered_set<string> seen; \n for (auto word : A) {\n string even, odd; \n for (int i = 0; i < word.size(); ++i) {\n if (i&1) odd.push_back(word[i]); \n else even.pus... | 4 | 0 | ['C'] | 0 |
groups-of-special-equivalent-strings | [typescript/javascript] o(n) solution w/ detailed comments + explanation | typescriptjavascript-on-solution-w-detai-9f72 | Forget what the problem is asking for a second. I\'ll dumb it down. It took me too long and I overthought way too hard.\nShout out to Fisher Coder (on youtube) | carti | NORMAL | 2020-09-23T05:24:35.415703+00:00 | 2020-09-23T05:24:35.415758+00:00 | 182 | false | Forget what the problem is asking for a second. I\'ll dumb it down. It took me too long and I overthought way too hard.\n*Shout out to Fisher Coder (on youtube) for explaining the problem statement. He\'s a legendary beast.*\n\nThe problem is **simply** asking how many strings are distinct, given you can swap any even-... | 4 | 0 | ['TypeScript', 'JavaScript'] | 1 |
groups-of-special-equivalent-strings | simple cpp solution using set | simple-cpp-solution-using-set-by-bitrish-4b8e | \nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& A) {\n ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n | bitrish | NORMAL | 2020-07-31T14:21:27.822835+00:00 | 2020-07-31T14:21:27.822891+00:00 | 346 | false | ```\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& A) {\n ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);\n unordered_set<string>mp;\n for(int i=0;i<A.size();i++)\n {\n string o="";\n string e="";\n for(int j=0;j<A[i].size();... | 4 | 1 | ['C', 'Ordered Set', 'C++'] | 2 |
groups-of-special-equivalent-strings | JAVA - Easy to Understand Solution | java-easy-to-understand-solution-by-anub-hmop | \npublic int numSpecialEquivGroups(String[] A) {\n\tHashSet<String> s = new HashSet<>();\n\tfor(String a : A) {\n\t\tint[] odd = new int[26], even = new int[26] | anubhavjindal | NORMAL | 2019-11-11T01:01:22.988940+00:00 | 2019-11-11T01:01:22.988973+00:00 | 322 | false | ```\npublic int numSpecialEquivGroups(String[] A) {\n\tHashSet<String> s = new HashSet<>();\n\tfor(String a : A) {\n\t\tint[] odd = new int[26], even = new int[26];\n\t\tfor(int i=0; i<a.length(); i++) {\n\t\t\tif(i%2==0)\n\t\t\t\teven[a.charAt(i)-\'a\']++;\n\t\t\telse\n\t\t\t\todd[a.charAt(i)-\'a\']++;\n\t\t}\n\t\ts.a... | 4 | 0 | [] | 0 |
groups-of-special-equivalent-strings | java 6ms solution, easy to understand with explanation | java-6ms-solution-easy-to-understand-wit-jvnt | The basic idea is putting the signature of each string to a set, then the size of set is the number of groups.\nSince each string only contains lowercase letter | pangeneral | NORMAL | 2019-04-09T06:05:12.164280+00:00 | 2019-04-09T06:05:12.164319+00:00 | 629 | false | The basic idea is putting the signature of each string to a set, then the size of set is the number of groups.\nSince each string only contains lowercase letters, we can use two arrays ```odd[26]``` and ```even[26]``` to represents the frequency of 26 lowercase letters on odd place and even place of a string repectivel... | 4 | 0 | ['Java'] | 0 |
groups-of-special-equivalent-strings | c++ | easy | faster | c-easy-faster-by-venomhighs7-vciu | \n\n# Code\n\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& A) {\n set<pair<string,string>> s;\n for (const auto& w : A) {\n | venomhighs7 | NORMAL | 2022-11-08T05:57:11.564554+00:00 | 2022-11-08T05:57:11.564590+00:00 | 500 | false | \n\n# Code\n```\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& A) {\n set<pair<string,string>> s;\n for (const auto& w : A) {\n pair<string,string> p;\n for (int i = 0; i < w.size (); ++i) {\n if (i % 2) p.first += w[i];\n else p.second += w[i];\... | 3 | 0 | ['C++'] | 0 |
groups-of-special-equivalent-strings | Simple C++ Code | simple-c-code-by-prosenjitkundu760-me8y | If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.\n\nclass Solution {\npublic:\n | _pros_ | NORMAL | 2022-06-21T02:24:57.160433+00:00 | 2022-06-21T02:24:57.160476+00:00 | 180 | false | # **If you like the implementation then Please help me by increasing my reputation. By clicking the up arrow on the left of my image.**\n```\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& words) {\n int n = words.size();\n unordered_map<string, int> um;\n for(string &word... | 3 | 0 | [] | 0 |
groups-of-special-equivalent-strings | easy, fast python solution | easy-fast-python-solution-by-pranavgarg0-dfmn | ```class Solution:\n def numSpecialEquivGroups(self, A: List[str]) -> int:\n dic={}\n for i in range(len(A)):\n x = \'\'.join(sorted | pranavgarg039 | NORMAL | 2021-02-20T14:20:44.811352+00:00 | 2021-02-20T14:20:44.811385+00:00 | 309 | false | ```class Solution:\n def numSpecialEquivGroups(self, A: List[str]) -> int:\n dic={}\n for i in range(len(A)):\n x = \'\'.join(sorted(A[i][0::2]))\n y = \'\'.join(sorted(A[i][1::2])) \n if (x+y) not in dic:\n dic[x+y]=1\n else:\n ... | 3 | 0 | [] | 2 |
groups-of-special-equivalent-strings | python 3, use defaultdict, 40ms (88.5%) | python-3-use-defaultdict-40ms-885-by-phi-x4ct | \n\nclass Solution:\n def numSpecialEquivGroups(self, A: List[str]) -> int:\n #\n helper = defaultdict(int)\n for string in A:\n | philno | NORMAL | 2020-12-06T16:48:13.790118+00:00 | 2020-12-06T16:48:13.790162+00:00 | 365 | false | \n```\nclass Solution:\n def numSpecialEquivGroups(self, A: List[str]) -> int:\n #\n helper = defaultdict(int)\n for string in A:\n key = "".join(sorted(string[0::2])+sorted(string[1::2]))\n helper[key] += 1\n return len(helper)\n``` | 3 | 0 | ['Python', 'Python3'] | 0 |
groups-of-special-equivalent-strings | Python 1 Liner and 5 Liner (for readability) Explained | python-1-liner-and-5-liner-for-readabili-4h8g | Since any even index can be switched with any other even index, and the same is true for any odd index pair, as long as two words share the same multiset of eve | rowe1227 | NORMAL | 2020-05-19T20:00:40.791001+00:00 | 2020-05-19T20:02:37.658451+00:00 | 171 | false | Since any even index can be switched with any other even index, and the same is true for any odd index pair, as long as two words share the same multiset of even-indexed letters and the same multiset of odd-indexed letters, then they are special-equivalent. \n\nThat said, we can represent any multiset by the sorted ev... | 3 | 0 | [] | 0 |
groups-of-special-equivalent-strings | Runtime 8 ms, C++ solution, using map | runtime-8-ms-c-solution-using-map-by-nip-0j18 | \nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& A) {\n unordered_map<string, int> count;\n for(auto s : A)\n {\n | nipaafroz | NORMAL | 2020-01-09T01:29:29.998635+00:00 | 2020-01-09T01:29:29.998696+00:00 | 186 | false | ```\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& A) {\n unordered_map<string, int> count;\n for(auto s : A)\n {\n string even = "", odd = "";\n for(int i = 0; i < s.size(); i++)\n {\n if(i % 2 == 0)\n ev... | 3 | 0 | [] | 1 |
groups-of-special-equivalent-strings | Java 2ms Solution with HashSet with Explanation | java-2ms-solution-with-hashset-with-expl-onqd | /\nJava Solution Beat 100% runtime and 100% memory\n\nit is kind of anagram problem.\ntwo strings can only be Special-Equivalent when BOTH their odd letters AN | albeit2008 | NORMAL | 2019-09-08T15:00:20.295349+00:00 | 2019-09-08T15:08:31.515591+00:00 | 876 | false | /*\nJava Solution Beat 100% runtime and 100% memory\n\nit is kind of anagram problem.\ntwo strings can only be Special-Equivalent when BOTH their odd letters AND even letters are anagrams.\n\nso based on above logic, \n1. we build hash value for each string, we sort odd position letters, even position letters of each ... | 3 | 0 | ['Sorting', 'Java'] | 2 |
groups-of-special-equivalent-strings | Python Solution | python-solution-by-user1996a-m8a6 | \n\ndef numSpecialEquivGroups(self, A):\n\t"""\n\t:type A: List[str]\n\t:rtype: int\n\t"""\n\tres = set()\n\tfor s in A:\n\t\ts = \'\'.join(sorted(s[::2]) + sor | user1996a | NORMAL | 2019-07-27T22:21:02.728868+00:00 | 2019-07-27T22:21:02.728899+00:00 | 417 | false | \n```\ndef numSpecialEquivGroups(self, A):\n\t"""\n\t:type A: List[str]\n\t:rtype: int\n\t"""\n\tres = set()\n\tfor s in A:\n\t\ts = \'\'.join(sorted(s[::2]) + sorted(s[1::2]))\n\t\tres.add(s)\n\treturn len(res)\n``` | 3 | 0 | ['Python3'] | 3 |
groups-of-special-equivalent-strings | my C++ solution | my-c-solution-by-tianboqiu-pwu0 | s1 is the substring containing only characters on odd position\ns2 is the substring containing only characters on even position\nsort s1 and s2, use s1 + s2 as | tianboqiu | NORMAL | 2018-11-12T15:15:18.784454+00:00 | 2018-11-12T15:15:18.784496+00:00 | 258 | false | s1 is the substring containing only characters on odd position\ns2 is the substring containing only characters on even position\nsort s1 and s2, use s1 + s2 as the key of that string\ncompare the key of each string\n```\n#include <unordered_set>\n#include <algorithm>\nusing std::unordered_set;\nclass Solution {\npublic... | 3 | 0 | [] | 0 |
groups-of-special-equivalent-strings | BruteForce Java Solution using sort(O(m*nlogn)) | bruteforce-java-solution-using-sortomnlo-smii | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n1. sort even and odd in | rajnarayansharma110 | NORMAL | 2024-10-19T13:04:12.132327+00:00 | 2024-10-19T13:04:12.132359+00:00 | 41 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. sort even and odd index seperate and put in a freq map\n2. hence more understandable approch\n# Complexity\n- Time complexity:O(m*nlogn)\n<!-- Add your time complex... | 2 | 0 | ['Java'] | 0 |
groups-of-special-equivalent-strings | Solution | solution-by-deleted_user-az8b | C++ []\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& words) {\n unordered_set<string> st;\n for (auto& w : words) {\n | deleted_user | NORMAL | 2023-05-11T08:45:34.782420+00:00 | 2023-05-11T10:03:33.404536+00:00 | 359 | false | ```C++ []\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& words) {\n unordered_set<string> st;\n for (auto& w : words) {\n string odd, even;\n for (int i = 0; i < w.size(); i++) {\n if (i % 2) even += w[i];\n else odd += w[i];\n... | 2 | 0 | ['C++', 'Java', 'Python3'] | 0 |
groups-of-special-equivalent-strings | Python Solution || run time 77% | python-solution-run-time-77-by-lalithkir-46vr | Code\n\nclass Solution(object):\n def numSpecialEquivGroups(self, words):\n """\n :type words: List[str]\n :rtype: int\n """\n | Lalithkiran | NORMAL | 2023-02-25T04:28:42.740365+00:00 | 2023-02-25T04:28:42.740396+00:00 | 344 | false | # Code\n```\nclass Solution(object):\n def numSpecialEquivGroups(self, words):\n """\n :type words: List[str]\n :rtype: int\n """\n lst=[]\n for i in words:\n evn=\'\'\n odd=\'\'\n for j in range(len(i)):\n if j%2==0:\n ... | 2 | 0 | ['Python'] | 0 |
groups-of-special-equivalent-strings | c++ | solution using set | simple approach | c-solution-using-set-simple-approach-by-iwndd | \nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& words) {\n set<string>s; // declare set of strings\n for(auto i:word | utkarshb1209 | NORMAL | 2023-02-04T16:38:58.192462+00:00 | 2023-02-04T16:38:58.192497+00:00 | 288 | false | ```\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& words) {\n set<string>s; // declare set of strings\n for(auto i:words){ \n string q="";\n string w="";\n for(int j=0;j<i.size();j++){\n if(j%2==0){\n q+=i[j... | 2 | 0 | ['C', 'Ordered Set'] | 0 |
groups-of-special-equivalent-strings | Java 92% Time | 94% Memory Solution | java-92-time-94-memory-solution-by-tbekp-5nfg | Approach\n1. To define groups I need to find smth common between strings, which belong to one group. So, I create 2 arrays with size of 26 (alph -> alphabet). I | tbekpro | NORMAL | 2022-12-20T06:28:52.989453+00:00 | 2022-12-20T06:28:52.989515+00:00 | 521 | false | # Approach\n1. To define groups I need to find smth common between strings, which belong to one group. So, I create 2 arrays with size of 26 (alph -> alphabet). Inside findAlphabet() I go through evenly indexed letters and increment the relevant index in the first alph array. The same applied to letters with odd indice... | 2 | 0 | ['Java'] | 0 |
groups-of-special-equivalent-strings | C++ sol using set | c-sol-using-set-by-night_wolf-nbsr | class Solution {\npublic:\n int numSpecialEquivGroups(vector& words) {\n unordered_set s;\n for(const auto& w : words){\n string odd | night_wolf | NORMAL | 2021-06-03T14:15:03.370112+00:00 | 2021-06-03T14:15:03.370158+00:00 | 114 | false | class Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& words) {\n unordered_set<string> s;\n for(const auto& w : words){\n string odd, even;\n for(int i=0;i<w.length();i++){\n \n if(i%2!=0) odd += w[i];\n even += w[i];}\n... | 2 | 0 | [] | 0 |
groups-of-special-equivalent-strings | Easy | Fast | Understandable | C++ Solution | easy-fast-understandable-c-solution-by-h-kjgk | UPVOTE IF THE SOLUTION MAKES SENSE TO YOU\n-> Solution to this problem as per this approach points to simple principle of dividing the string in to two parts - | hardy30894 | NORMAL | 2021-02-19T12:37:39.547657+00:00 | 2021-02-20T14:02:10.533778+00:00 | 219 | false | UPVOTE IF THE SOLUTION MAKES SENSE TO YOU\n-> Solution to this problem as per this approach points to simple principle of dividing the string in to two parts - \n - One string with characters from odd indexes.\n - One string with characters from even indexes.\n \n Once we have these two individual parts, sort specific ... | 2 | 0 | ['C'] | 0 |
groups-of-special-equivalent-strings | Python3 one liner solution faster than 69% | python3-one-liner-solution-faster-than-6-ixw2 | \nclass Solution:\n def numSpecialEquivGroups(self, A: List[str]) -> int:\n return len({\'\'.join(sorted(a[::2]) + sorted(a[1::2])) for a in A})\n | mhviraf | NORMAL | 2021-02-17T04:14:39.627459+00:00 | 2021-02-17T04:14:54.901787+00:00 | 464 | false | ```\nclass Solution:\n def numSpecialEquivGroups(self, A: List[str]) -> int:\n return len({\'\'.join(sorted(a[::2]) + sorted(a[1::2])) for a in A})\n``` | 2 | 0 | ['Python', 'Python3'] | 0 |
groups-of-special-equivalent-strings | C++ (4 ms) without sorting; beats 100% time 99% space | c-4-ms-without-sorting-beats-100-time-99-fjee | In this problem, it is understood that for a string if we maintain 2 hashsets for count of characters in odd and even places, and if both these hashsets match ( | mihiraman | NORMAL | 2020-07-03T08:41:57.344133+00:00 | 2020-07-03T08:47:12.042839+00:00 | 166 | false | In this problem, it is understood that for a string if we maintain 2 hashsets for count of characters in odd and even places, and if both these hashsets match (corresponding) for 2 given strings, then both the strings can be grouped together i.e. are equivalent.\n\nBut to maintain a set of hashsets is a tedious job.\n\... | 2 | 0 | [] | 0 |
groups-of-special-equivalent-strings | Ruby solution. Represent word as array of 52 elements with 2 histograms in it. | ruby-solution-represent-word-as-array-of-a4wt | Leetcode: 893. Groups of Special-Equivalent Strings.\n\n\n\n##### Simplified approach.\n\nthnx @quantumlexa \n\nTwo strings are special equivalent if their his | user9697n | NORMAL | 2020-06-23T16:29:27.418602+00:00 | 2020-06-23T16:50:28.888434+00:00 | 157 | false | #### Leetcode: 893. Groups of Special-Equivalent Strings.\n\n\n\n##### Simplified approach.\n\n`thnx @quantumlexa` \n\nTwo strings are special equivalent if their histograms for even and odd indices are equal. Histogram for a word can be represented as 52 elments array, 26 for even 26 for odd symbols. Array mapped fro... | 2 | 0 | ['Ruby'] | 1 |
groups-of-special-equivalent-strings | Easy Python Solution | easy-python-solution-by-ayu-99-fwf9 | \nclass Solution:\n def numSpecialEquivGroups(self, A: List[str]) -> int:\n l=[]\n for s in A:\n even=""\n odd=""\n | ayu-99 | NORMAL | 2020-04-11T19:27:17.005304+00:00 | 2020-04-11T19:27:17.005333+00:00 | 244 | false | ```\nclass Solution:\n def numSpecialEquivGroups(self, A: List[str]) -> int:\n l=[]\n for s in A:\n even=""\n odd=""\n for i in range(len(s)):\n if i%2!=0:\n odd+=s[i]\n \n else:\n ev... | 2 | 0 | ['String', 'Python'] | 0 |
groups-of-special-equivalent-strings | [Python3] Group strings by sorting characters at even & odd indices | python3-group-strings-by-sorting-charact-513c | Algorithm:\nHere, we need a way to group strings so that each group is a special-equivalent group. Counting is one way as suggested by the Solution. Here, I\'ve | ye15 | NORMAL | 2020-02-17T22:42:16.893674+00:00 | 2020-02-17T22:42:16.893708+00:00 | 283 | false | Algorithm:\nHere, we need a way to group strings so that each group is a special-equivalent group. Counting is one way as suggested by the Solution. Here, I\'ve used sorting-based approach. For a given string, sort the characters at even and odd indices respectively and join them. \n\n(36ms, 96.54%): \n```\nclass Solut... | 2 | 0 | ['Python3'] | 1 |
groups-of-special-equivalent-strings | Go 0ms map solution | go-0ms-map-solution-by-tjucoder-9lod | go\nfunc numSpecialEquivGroups(A []string) int {\n m := map[[52]int]interface{}{}\n for _, s := range A {\n array := [52]int{}\n for i, c := | tjucoder | NORMAL | 2020-02-14T14:53:28.782508+00:00 | 2020-02-14T14:53:28.782544+00:00 | 107 | false | ```go\nfunc numSpecialEquivGroups(A []string) int {\n m := map[[52]int]interface{}{}\n for _, s := range A {\n array := [52]int{}\n for i, c := range s {\n if i % 2 == 0 {\n array[c-\'a\']++\n } else {\n array[c-\'a\'+26]++\n }\n ... | 2 | 0 | ['Go'] | 0 |
groups-of-special-equivalent-strings | java 4ms , customized hashing algorithm ,easy to understand | java-4ms-customized-hashing-algorithm-ea-kz59 | customized a hashing algorithm that:\n1.split the string into 2 parts by index , the odd part and the even part\n2.count each char (a ~ z) in each part\n3.combi | powerrc | NORMAL | 2019-05-09T22:36:10.798819+00:00 | 2019-05-09T22:36:10.798849+00:00 | 239 | false | customized a hashing algorithm that:\n1.split the string into 2 parts by index , the odd part and the even part\n2.count each char (a ~ z) in each part\n3.combine the count result into a hashing string\n4.just add hashing string into a set\n5.return the size of this set\n```\nclass Solution {\n \n private String ... | 2 | 0 | [] | 1 |
groups-of-special-equivalent-strings | Python Easy to Understand 1-liner + other faster solution | python-easy-to-understand-1-liner-other-ky3ch | In the one liner, you just return the length of the set of tuples. Each tuple contain (sorted letters of even indexed letters, sorted letters of odd indexed let | rosemelon | NORMAL | 2019-05-07T00:51:25.071738+00:00 | 2019-05-07T00:51:25.071782+00:00 | 242 | false | In the one liner, you just return the length of the set of tuples. Each tuple contain (sorted letters of even indexed letters, sorted letters of odd indexed letters). This should be O(N*klogk), with k being the length of each word.\n\n`return len(set(tuple(sorted(word[::2])+sorted(word[1::2])) for word in A))`\n\nThis ... | 2 | 0 | [] | 0 |
groups-of-special-equivalent-strings | python3 one-liner | python3-one-liner-by-xdavidliu-tm9s | \n def numSpecialEquivGroups(self, A):\n return len({\'\'.join(sorted(word[::2]))+\'\'.join(sorted(word[1::2])) for word in A})\n\nuses letters at eve | xdavidliu | NORMAL | 2018-11-08T02:42:03.396652+00:00 | 2018-11-08T02:42:03.396722+00:00 | 265 | false | ```\n def numSpecialEquivGroups(self, A):\n return len({\'\'.join(sorted(word[::2]))+\'\'.join(sorted(word[1::2])) for word in A})\n```\nuses letters at even positions, sorted, and letters at odd positions, also sorted, and combines them into a single string used as they key for a set, then returns the length... | 2 | 0 | [] | 1 |
groups-of-special-equivalent-strings | Possible javascript solution with map and sort | possible-javascript-solution-with-map-an-ufx3 | \nvar numSpecialEquivGroups = function(A) {\n var odd;\n var even;\n var key;\n var count = 0;\n var map = Object.create(null);\n for (var i = | eforce | NORMAL | 2018-09-12T09:55:56.313120+00:00 | 2018-09-13T23:22:45.003322+00:00 | 252 | false | ```\nvar numSpecialEquivGroups = function(A) {\n var odd;\n var even;\n var key;\n var count = 0;\n var map = Object.create(null);\n for (var i = 0; i < A.length; i++) {\n odd = [];\n even = [];\n for (var j = 0; j < A[i].length; j++) {\n if (j % 2 === 0) {\n ... | 2 | 0 | [] | 0 |
groups-of-special-equivalent-strings | c++ solution beats 100% | c-solution-beats-100-by-hupodezhu-z3vj | class Solution {\npublic:\n int numSpecialEquivGroups(vector& A) {\n set s;\n \n for (auto &a : A) {\n string s1;\n | hupodezhu | NORMAL | 2018-08-28T06:07:03.235420+00:00 | 2018-08-28T06:07:03.235462+00:00 | 299 | false | class Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& A) {\n set<string> s;\n \n for (auto &a : A) {\n string s1;\n string s2;\n for (int i = 0; i < a.size(); i++) {\n if (i % 2 == 0)\n s1 += a[i];\n ... | 2 | 0 | [] | 1 |
groups-of-special-equivalent-strings | Python Straightforward Solution | python-straightforward-solution-by-zetru-xq4t | \nclass Solution(object):\n\tdef numSpecialEquivGroups(self, A):\n\t\t"""\n\t\t:type A: List[str]\n\t\t:rtype: int\n\t\t"""\n\t\tB = set()\n\t\tfor string in A: | zetrue_li | NORMAL | 2018-08-26T07:03:16.137190+00:00 | 2018-09-06T05:28:10.939930+00:00 | 435 | false | ```\nclass Solution(object):\n\tdef numSpecialEquivGroups(self, A):\n\t\t"""\n\t\t:type A: List[str]\n\t\t:rtype: int\n\t\t"""\n\t\tB = set()\n\t\tfor string in A:\n\t\t\tC = list(string)\n\t\t\ta, b = C[::2], C[1::2]\n\t\t\tB.add((\'\'.join(sorted(a)), \'\'.join(sorted(b))))\n\t\t\t\n\t\treturn len(B)\n``` | 2 | 1 | [] | 4 |
groups-of-special-equivalent-strings | beats 100% | beats-100-by-giri_69-ypq5 | IntuitionThe approach is same as : https://leetcode.com/problems/check-if-strings-can-be-made-equal-with-operations-ii/solutions/6381305/beats-100-c-by-giri_69- | giri_69 | NORMAL | 2025-02-05T17:54:36.947686+00:00 | 2025-02-05T17:54:36.947686+00:00 | 68 | false | # Intuition
The approach is same as : https://leetcode.com/problems/check-if-strings-can-be-made-equal-with-operations-ii/solutions/6381305/beats-100-c-by-giri_69-ld12/
The only diff is for grouping group the characters at even and odd index of strings together
# Code
```cpp []
class Solution {
public:
int numSpe... | 1 | 0 | ['C++'] | 0 |
groups-of-special-equivalent-strings | Java brute force | java-brute-force-by-ihatealgothrim-m4p7 | Intuition\nwords[i] and words[j]are special-equivalent means both have the same odd indexed chars, and even indexed chars\n\n# Approach\n- Each word, we can hav | IHateAlgothrim | NORMAL | 2024-05-18T09:09:19.199669+00:00 | 2024-05-18T09:09:19.199697+00:00 | 167 | false | # Intuition\n```words[i]``` and ```words[j]```are **special-equivalent** means both have the same odd indexed chars, and even indexed chars\n\n# Approach\n- Each word, we can have two temp storages, ```int[] odds = new int[26]```, and ```int[] evens = new int[26]```, which we can merge to ```int alphabet = new int[52]`... | 1 | 0 | ['Java'] | 0 |
groups-of-special-equivalent-strings | 100% beat | 100-beat-by-somaycoder-7mm7 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | somaycoder | NORMAL | 2024-04-17T21:13:02.198757+00:00 | 2024-04-17T21:13:02.198777+00:00 | 252 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['Array', 'Hash Table', 'Sorting', 'C++'] | 1 |
groups-of-special-equivalent-strings | Java Easy Solution | java-easy-solution-by-krishnachaubey2799-kqr1 | Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time | krishnachaubey2799 | NORMAL | 2023-02-14T04:41:35.415535+00:00 | 2023-02-14T04:41:35.415581+00:00 | 418 | false | # Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ --... | 1 | 0 | ['Java'] | 0 |
groups-of-special-equivalent-strings | Pyton3 easy to understand solution | pyton3-easy-to-understand-solution-by-0i-r0ym | Approach\nSort the odd indices and even indices of the word seperately. Then combine those 2 to get the key value which is the same for special equivalent strin | 0icy | NORMAL | 2023-01-30T08:29:20.232591+00:00 | 2023-01-30T08:29:20.232637+00:00 | 449 | false | # Approach\nSort the odd indices and even indices of the word seperately. Then combine those 2 to get the key value which is the same for special equivalent strings.\n\n\n\n# Code\n```\nfrom collections import defaultdict\nclass Solution:\n def numSpecialEquivGroups(self, words: List[str]) -> int:\n d = defau... | 1 | 0 | ['Python3'] | 0 |
groups-of-special-equivalent-strings | General Approach | general-approach-by-abhichauhan5682-2tz1 | Intuition\nOdd index characters should be same and even index characters should be same for 2 different strings\n Describe your first thoughts on how to solve t | abhichauhan5682 | NORMAL | 2023-01-06T11:09:38.707855+00:00 | 2023-01-06T11:09:38.707895+00:00 | 99 | false | # Intuition\nOdd index characters should be same and even index characters should be same for 2 different strings\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: O(n^2*(20+20log20)\n<!-- Add y... | 1 | 0 | ['C++'] | 0 |
groups-of-special-equivalent-strings | Solution, Runtime 16 ms, faster than 63.18% and Memory 8.8 MB, less than 68.16% of C++submissions | solution-runtime-16-ms-faster-than-6318-thv93 | The idea is really very naive \uD83D\uDE05\uD83D\uDE05 .....the thought was if i create a unique key for a single group of equivalent strings\n\n-> Take even po | Indominous1 | NORMAL | 2022-10-30T16:46:56.853933+00:00 | 2022-11-17T19:15:24.524023+00:00 | 244 | false | The idea is really very naive \uD83D\uDE05\uD83D\uDE05 .....the thought was if i create a unique key for a single group of equivalent strings\n\n-> Take even poisitioned characters and add them to form a string, then take odd poisitioned characters and add them to form a string.\n-> Now, sort both the strings as the qu... | 1 | 0 | ['Array', 'Hash Table', 'Math', 'C', 'C++'] | 0 |
groups-of-special-equivalent-strings | C++ easy solution using sets and hashmaps | c-easy-solution-using-sets-and-hashmaps-0ptia | \n\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector& words) {\n int n=words.size();\n vector>v;\n \n for(auto it:wor | agarwalayush007 | NORMAL | 2022-08-27T17:04:46.195403+00:00 | 2022-08-27T17:04:46.195436+00:00 | 120 | false | \n\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& words) {\n int n=words.size();\n vector<pair<string,string>>v;\n \n for(auto it:words)\n {\n string even="";\n string odd="";\n for(int i=0;i<it.size();i+=2)even+=it[i];\n ... | 1 | 0 | ['C', 'Ordered Set'] | 0 |
groups-of-special-equivalent-strings | Python O(n*m) HashMap 83.04% | python-onm-hashmap-8304-by-ya-anarka-uwju | \ndef numSpecialEquivGroups(self, words: List[str]) -> int:\n d = {}\n for word in words:\n even = [0] * 26\n odd = [0] * 26 | ya-anarka | NORMAL | 2022-08-27T05:33:13.508530+00:00 | 2022-08-27T05:35:52.166886+00:00 | 219 | false | ```\ndef numSpecialEquivGroups(self, words: List[str]) -> int:\n d = {}\n for word in words:\n even = [0] * 26\n odd = [0] * 26\n for i, c in enumerate(word):\n if i % 2 == 0:\n even[ord(c) - ord(\'a\')] += 1\n else:\n ... | 1 | 0 | ['Counting Sort', 'Python'] | 0 |
groups-of-special-equivalent-strings | Python, 1 line | python-1-line-by-kingseaview-za9k | \nreturn len(Counter(\'\'.join(sorted(w[::2])+sorted(w[1::2])) for w in words))\n | kingseaview | NORMAL | 2022-08-16T15:11:41.190344+00:00 | 2022-08-16T15:11:41.190375+00:00 | 199 | false | ```\nreturn len(Counter(\'\'.join(sorted(w[::2])+sorted(w[1::2])) for w in words))\n``` | 1 | 0 | [] | 0 |
groups-of-special-equivalent-strings | A sort and simple solution in C++ | a-sort-and-simple-solution-in-c-by-rvraj-lgwd | ```\n\t\t\n int numSpecialEquivGroups(vector& words) {\n \n set s;\n \n for(int i=0;i<words.size();i++){\n \n | Rvraj | NORMAL | 2022-04-09T05:33:13.163432+00:00 | 2022-04-09T05:34:46.783303+00:00 | 73 | false | ```\n\t\t\n int numSpecialEquivGroups(vector<string>& words) {\n \n set<string> s;\n \n for(int i=0;i<words.size();i++){\n \n string st = words[i];\n string odd = "";\n string even = "";\n \n for(int j=0;j<st.size();j++){\n... | 1 | 0 | [] | 0 |
groups-of-special-equivalent-strings | Easy C++ solution | easy-c-solution-by-imran2018wahid-0ry0 | \nclass Solution {\npublic:\n // This function stores the character frequency of the odd and even positions of a string\n void filler(string &str,vector<i | imran2018wahid | NORMAL | 2021-12-07T03:57:41.304981+00:00 | 2021-12-07T03:57:41.305009+00:00 | 130 | false | ```\nclass Solution {\npublic:\n // This function stores the character frequency of the odd and even positions of a string\n void filler(string &str,vector<int>&odd,vector<int>&even) {\n for(int i=0;i<str.length();i++) {\n if(i%2==0) {\n even[str[i]-\'a\']++;\n }\n ... | 1 | 0 | ['C'] | 1 |
groups-of-special-equivalent-strings | JAVA || HashSet || very easy | java-hashset-very-easy-by-ayushx-jv8o | \n public int numSpecialEquivGroups(String[] words) {\n HashSet<String> record = new HashSet<>();\n for (String str: words) {\n int[] | ayushx | NORMAL | 2021-08-19T16:49:45.992293+00:00 | 2021-08-19T16:49:45.992330+00:00 | 202 | false | ```\n public int numSpecialEquivGroups(String[] words) {\n HashSet<String> record = new HashSet<>();\n for (String str: words) {\n int[] even = new int[26];\n int[] odd = new int[26];\n for (int i = 0; i < str.length(); i++) {\n if (i % 2 == 0) {\n ... | 1 | 0 | ['Java'] | 0 |
groups-of-special-equivalent-strings | Python3 | Hashset | python3-hashset-by-swapnilsingh421-s9hv | TIME COMPLEXITY - O ( n * len ( word[ i ] ) )\nSPACE COMPLEXITY - O(N) in worst case\n\nclass Solution:\n def numSpecialEquivGroups(self, words: List[str]) - | swapnilsingh421 | NORMAL | 2021-08-06T13:08:11.942927+00:00 | 2021-08-06T13:08:11.942955+00:00 | 174 | false | TIME COMPLEXITY - O ( n * len ( word[ i ] ) )\nSPACE COMPLEXITY - O(N) in worst case\n```\nclass Solution:\n def numSpecialEquivGroups(self, words: List[str]) -> int:\n hset=set()\n for i in range(len(words)):\n even=[0]*26\n odd=[0]*26\n for j in range(len(words[i])):\... | 1 | 0 | ['Python3'] | 0 |
groups-of-special-equivalent-strings | Java | Straight forward with explanation and example | java-straight-forward-with-explanation-a-f9li | \nQuestion is super convoluted. You just want the max number of string pair where if you can switch any even index char and/or odd index char, they match.\n\nUs | ssong716 | NORMAL | 2021-07-29T02:13:50.848603+00:00 | 2021-07-29T02:13:50.848639+00:00 | 92 | false | \nQuestion is super convoluted. You just want the max number of string pair where if you can switch any even index char and/or odd index char, they match.\n\nUsing the given example, this is the mental mapping you want: \n```\n["abcd","cdab","cbad","xyzz","zzxy","zzyx"]\nabcd -> ac | bd\ncbad -> ac | bd\nxyzz -> xz | y... | 1 | 0 | [] | 0 |
groups-of-special-equivalent-strings | C++: Very easy to understand solution | c-very-easy-to-understand-solution-by-ra-5uyy | \nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& words) {\n unordered_map<string, bool> umap;\n int ans = 0;\n fo | rani_here_121 | NORMAL | 2021-07-27T12:49:34.877551+00:00 | 2021-07-27T12:49:34.877581+00:00 | 87 | false | ```\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& words) {\n unordered_map<string, bool> umap;\n int ans = 0;\n for(int i=0; i<words.size(); i++){\n string odd = "";\n string even = "";\n for(int j=0; j<words[i].length(); j++){\n ... | 1 | 0 | [] | 0 |
groups-of-special-equivalent-strings | Java | 90% faster | java-90-faster-by-shashank_tiwari1801-ffaq | \nclass Solution {\n String sortString(String str) {\n char []arr = str.toCharArray();\n Arrays.sort(arr);\n return (String.valueOf(arr) | Shashank_Tiwari1801 | NORMAL | 2021-07-04T13:19:51.520574+00:00 | 2021-07-04T13:19:51.520610+00:00 | 87 | false | ```\nclass Solution {\n String sortString(String str) {\n char []arr = str.toCharArray();\n Arrays.sort(arr);\n return (String.valueOf(arr));\n }\n public int numSpecialEquivGroups(String[] words) {\n HashSet<String> set = new HashSet<>();\n for(String s:words){\n ... | 1 | 0 | [] | 0 |
groups-of-special-equivalent-strings | Poor description | poor-description-by-yashoda_agrawal-eiq8 | This question has a simple solution. but it took alot of time to just understand the question\n\n\nclass Solution {\n public int numSpecialEquivGroups(String | yashoda_agrawal | NORMAL | 2021-07-02T21:47:22.570120+00:00 | 2021-07-02T21:49:11.212863+00:00 | 62 | false | This question has a simple solution. but it took alot of time to just understand the question\n\n```\nclass Solution {\n public int numSpecialEquivGroups(String[] words) {\n int len=words[0].length();\n int max=0;\n Map<String, Integer> map=new HashMap();\n for(String s:wo... | 1 | 0 | [] | 0 |
groups-of-special-equivalent-strings | c++ simple , aesy to understand solution | c-simple-aesy-to-understand-solution-by-3exru | \nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& words) {\n int i=0,n=words.size();\n vector<vector<string>> res;\n\n while(i | shubham7737 | NORMAL | 2021-06-20T09:31:25.545359+00:00 | 2021-06-20T09:31:25.545400+00:00 | 102 | false | ```\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& words) {\n int i=0,n=words.size();\n vector<vector<string>> res;\n\n while(i<n){\n int j=0,m=words[i].length();\n string strt=words[i],t1="",t2="";\n while(j<m){\n\n if(j%2==0){\n t1+=st... | 1 | 0 | [] | 0 |
groups-of-special-equivalent-strings | C++ 4ms (sorting) | c-4ms-sorting-by-wondertx-x1ts | \nclass Solution {\npublic:\n int numSpecialEquivGroups(std::vector<std::string>& words) {\n std::set<std::string> normed;\n for (auto && word : words) { | wondertx | NORMAL | 2021-06-15T11:14:23.145453+00:00 | 2021-06-15T11:14:23.145499+00:00 | 98 | false | ```\nclass Solution {\npublic:\n int numSpecialEquivGroups(std::vector<std::string>& words) {\n std::set<std::string> normed;\n for (auto && word : words) {\n sortStr(word);\n normed.insert(word);\n }\n return normed.size();\n }\n\n void sortStr(std::string& word) {\n using std::swap;\n f... | 1 | 0 | [] | 0 |
groups-of-special-equivalent-strings | [with explanation] Python 40 ms faster than 80% and easy solution and one liner as well | with-explanation-python-40-ms-faster-tha-dey7 | \nclass Solution:\n def numSpecialEquivGroups(self, words: List[str]) -> int:\n result = set()\n for i in words:\n i = \'\'.join(sor | alimlalani | NORMAL | 2021-06-12T03:30:17.425975+00:00 | 2021-06-12T03:33:35.146154+00:00 | 85 | false | ```\nclass Solution:\n def numSpecialEquivGroups(self, words: List[str]) -> int:\n result = set()\n for i in words:\n i = \'\'.join(sorted(i[::2]) + sorted(i[1::2]))\n result.add(i)\n return (len(result))\n\n```\n\'\'\'\t\t\nThe list indices which we have used ([::2]) and (... | 1 | 0 | [] | 0 |
groups-of-special-equivalent-strings | Share two Java solutions | share-two-java-solutions-by-ly2015cntj-57zh | java\n// \u65B9\u6CD5\u4E8C\uFF1A\u5F97\u5230\u6BCF\u4E2A\u5B57\u7B26\u4E32\u7684\u5947\u6570\u4F4D\u548C\u5076\u6570\u4F4D\u7EDF\u8BA1\u60C5\u51B5\u4EE5\u540E\ | ly2015cntj | NORMAL | 2021-05-18T14:12:46.282562+00:00 | 2021-05-18T14:12:46.282606+00:00 | 230 | false | ```java\n// \u65B9\u6CD5\u4E8C\uFF1A\u5F97\u5230\u6BCF\u4E2A\u5B57\u7B26\u4E32\u7684\u5947\u6570\u4F4D\u548C\u5076\u6570\u4F4D\u7EDF\u8BA1\u60C5\u51B5\u4EE5\u540E\uFF0C\u7EC4\u6210\u4E00\u4E2A\u7279\u5F81\u5B57\u7B26\u4E32\u5B58\u5165 set\uFF0C\u7528 set \u53BB\u91CD\n// AC: Runtime: 13 ms, faster than 55.72% of Java o... | 1 | 0 | ['Java'] | 0 |
groups-of-special-equivalent-strings | java | java-by-190030070-vj1u | class Solution {\n public static int numSpecialEquivGroups(String[] A) {\n Set set = new HashSet<>();\n\n for (String s : A) {\n int | 190030070 | NORMAL | 2021-03-18T06:13:37.637687+00:00 | 2021-03-18T06:13:37.637718+00:00 | 130 | false | class Solution {\n public static int numSpecialEquivGroups(String[] A) {\n Set<String> set = new HashSet<>();\n\n for (String s : A) {\n int[] even = new int[26];\n int[] odd = new int[26];\n\n for (int i=0; i<s.length(); i++) {\n if (i%2 == 0) {\n ... | 1 | 0 | [] | 0 |
groups-of-special-equivalent-strings | C++ solution | c-solution-by-oleksam-qr9b | \nint numSpecialEquivGroups(vector<string>& A) {\n\tset<string> sWords;\n\tfor (string w : A) {\n\t\tstring even = "", odd = "";\n\t\tfor (int i = 0; i < w.size | oleksam | NORMAL | 2021-01-29T21:03:08.661930+00:00 | 2021-01-29T21:07:49.318054+00:00 | 169 | false | ```\nint numSpecialEquivGroups(vector<string>& A) {\n\tset<string> sWords;\n\tfor (string w : A) {\n\t\tstring even = "", odd = "";\n\t\tfor (int i = 0; i < w.size(); i += 2) {\n\t\t\teven += w[i];\n\t\t\todd += w[i + 1];\n\t\t}\n\t\tsort(begin(even), end(even));\n\t\tsort(begin(odd), end(odd));\n\t\tw = even + odd;\n\... | 1 | 0 | ['C', 'C++'] | 0 |
groups-of-special-equivalent-strings | 1 liner Python solution | 1-liner-python-solution-by-faceplant-y8rf | \nreturn len({("".join(sorted(list(s[::2]))), "".join(sorted(list(s[1::2])))) for s in A})\n | FACEPLANT | NORMAL | 2021-01-17T15:50:34.445480+00:00 | 2021-01-17T15:50:34.445522+00:00 | 152 | false | ```\nreturn len({("".join(sorted(list(s[::2]))), "".join(sorted(list(s[1::2])))) for s in A})\n``` | 1 | 1 | [] | 0 |
groups-of-special-equivalent-strings | C++|| 100% fast, simple solution | c-100-fast-simple-solution-by-know_go-5f5u | \nclass Solution{\n public:\n int numSpecialEquivGroups(vector<string>& A) {\n //00 sort the letter in strings in A:\n for(auto& word : A) { | know_go | NORMAL | 2020-12-29T14:38:23.003323+00:00 | 2020-12-29T14:38:23.003407+00:00 | 120 | false | ```\nclass Solution{\n public:\n int numSpecialEquivGroups(vector<string>& A) {\n //00 sort the letter in strings in A:\n for(auto& word : A) {\n string s1, s2;\n for(int i = 0; i < word.size(); i += 2) {\n s1 += word[i];\n s2 += word[i + 1];\n ... | 1 | 0 | [] | 1 |
groups-of-special-equivalent-strings | C++ straightforward solution | c-straightforward-solution-by-nc-2mhw | \nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& A) {\n unordered_set<string> groups;\n \n for (auto& s: A) {\n | nc_ | NORMAL | 2020-12-14T06:33:16.419271+00:00 | 2020-12-14T06:33:16.419303+00:00 | 98 | false | ```\nclass Solution {\npublic:\n int numSpecialEquivGroups(vector<string>& A) {\n unordered_set<string> groups;\n \n for (auto& s: A) {\n string odd, even;\n for (int i = 0; i < s.size(); ++i)\n if (i%2)\n odd.push_back(s[i]);\n ... | 1 | 0 | [] | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.